Jump to content

hey guys,

 

so im working with MS ACCESS 2013 and here is my sql query:

 

SELECT        Kennzeichen, Kategorie, Fahrerlaubnis, TÜV, Service, Defekt, DefektArt, DefektDatum, Hebebuhne, HebebuhneTuv, IIF(ISNULL(HebebuhneTuv) OR HebebuhneTuv = "", '30.12.9999', HebebuhneTuv) AS ttuv  
FROM            Fahrzeuge 
WHERE (CDate(ttuv) <= CDate(?))
 
firstly sorry for the german field names. secondly HebebuhneTuv represents a date ind varchar form and i want to raplace all empty or null values with the super high value and then ask to show only those entry where the date is smaller than today.
 
problem is access doesnt recognize the custom field name ttuv in the where clause and is asking me for its value. all i want to do is exclude entry with null or empty values. it cant be this hard can it?
 
thanks for any help at all

"You know it'll clock down as soon as it hits 40°C, right?" - "Yeah ... but it doesnt hit 40°C ... ever  😄"

 

GPU: MSI GTX1080 Ti Aero @ 2 GHz (watercooled) CPU: Ryzen 5600X (watercooled) RAM: 32GB 3600Mhz Corsair LPX MB: Gigabyte B550i PSU: Corsair SF750 Case: Hyte Revolt 3

 

Link to comment
https://linustechtips.com/topic/413523-quick-sql-help-needed-please/
Share on other sites

Link to post
Share on other sites

Talk me through how you're trying to define the ttuv, exactly.

 

I'm not sure your "AS" statement is valid here. But it's way too early for my brain.

 

Nice quote in your signature, by the way.

DayZ Forum Moderator, DayZ Developer, ARMA 3: 2017 Developer, System-Admin, Gameserver-Admin, always interested to learn something new as well as new people.

Link to post
Share on other sites

 

hey guys,

 

so im working with MS ACCESS 2013 and here is my sql query:

 

SELECT        Kennzeichen, Kategorie, Fahrerlaubnis, TÜV, Service, Defekt, DefektArt, DefektDatum, Hebebuhne, HebebuhneTuv, IIF(ISNULL(HebebuhneTuv) OR HebebuhneTuv = "", '30.12.9999', HebebuhneTuv) AS ttuv  
FROM            Fahrzeuge 
WHERE (CDate(ttuv) <= CDate(?))
 
firstly sorry for the german field names. secondly HebebuhneTuv represents a date ind varchar form and i want to raplace all empty or null values with the super high value and then ask to show only those entry where the date is smaller than today.
 
problem is access doesnt recognize the custom field name ttuv in the where clause and is asking me for its value. all i want to do is exclude entry with null or empty values. it cant be this hard can it?
 
thanks for any help at all

 

I also would like some definition of ttuv.

I mean.. isnt AS just for output? can you actually read the table-alias in the query it's created itself (-> "WHERE (CDate(ttuv)")?

I'd split this into 2 queries: one for the exclude and one to read from the resulting table

Bitfenix Phenom M White | ASUS RoG Maximus VIII Gene | Intel i7 6700K @4.6GHz | HyperX Savage 2800MHz CL14 DDR4 16GB | EVGA GTX1080 SC | Intel 750 Series PCIe SSD 400GB | EVGA SuperNova G2 550W | Windows 10 Professional x64 | Logitech G900, Corsair K70 RGB MXbrown O-ringed, BeyerDynamic DT880 (600 Ω) on Fiio E10K & Samson Meteor | Dell U2715H 27", Samsung SyncMaster P2450H 24", Samsung SyncMaster 931BF 19" | DIY Ambilight

Link to post
Share on other sites

Talk me through how you're trying to define the ttuv, exactly.

 

I'm not sure your "AS" statement is valid here. But it's way too early for my brain.

 

Nice quote in your signature, by the way.

thanks :D yeah its a little early for me too maybe thats why i dont see it.

so basicly im just trying to get all entries where HebebuhneTuv is smaller than a date of my choosing. the problem is that HebebuhneTuv also can be null or empty in which case CDate would throw an exception so i have to exclude all entries with null or empty

"You know it'll clock down as soon as it hits 40°C, right?" - "Yeah ... but it doesnt hit 40°C ... ever  😄"

 

GPU: MSI GTX1080 Ti Aero @ 2 GHz (watercooled) CPU: Ryzen 5600X (watercooled) RAM: 32GB 3600Mhz Corsair LPX MB: Gigabyte B550i PSU: Corsair SF750 Case: Hyte Revolt 3

 

Link to post
Share on other sites

I also would like some definition of ttuv.

I mean.. isnt AS just for output? can you actually read the table-alias in the query it's created itself (-> "WHERE (CDate(ttuv)")?

I'd split this into 2 queries: one for the exclude and one to read from the resulting table

yeah that seems to be the problem using ttuv in where clause doesnt work i redid the whole a little and now it seems to work 

 

SELECT        Kennzeichen, Kategorie, Fahrerlaubnis, TÜV, Service, Defekt, DefektArt, DefektDatum, Hebebuhne, HebebuhneTuv
FROM            Fahrzeuge 
WHERE CDate(IIF(ISNULL(HebebuhneTuv) OR HebebuhneTuv = "", '30.12.9999', HebebuhneTuv)) <= CDate(@Date)

"You know it'll clock down as soon as it hits 40°C, right?" - "Yeah ... but it doesnt hit 40°C ... ever  😄"

 

GPU: MSI GTX1080 Ti Aero @ 2 GHz (watercooled) CPU: Ryzen 5600X (watercooled) RAM: 32GB 3600Mhz Corsair LPX MB: Gigabyte B550i PSU: Corsair SF750 Case: Hyte Revolt 3

 

Link to post
Share on other sites

the problem here is in the table structure itself: if HebebuhneTuv is a date, then why are you storing it as a string?

having it as a string forces you to write weird hacks like this, makes it possible for the db to enter a corrupted state, and makes this query much much slower because access can't use any index

Link to post
Share on other sites

the problem here is in the table structure itself: if HebebuhneTuv is a date, then why are you storing it as a string?

having it as a string forces you to write weird hacks like this, makes it possible for the db to enter a corrupted state, and makes this query much much slower because access can't use any index

the db behind it is not for me to change and i also didnt design it. i also am very confused and sometimes angry because he stored everything like this. also he didnt use foreign keys or any relations whatsoever. there are no constraints. this db is a mess but i gots to work with it and make the best with what i have ..... oh and kill the original designer obviously

"You know it'll clock down as soon as it hits 40°C, right?" - "Yeah ... but it doesnt hit 40°C ... ever  😄"

 

GPU: MSI GTX1080 Ti Aero @ 2 GHz (watercooled) CPU: Ryzen 5600X (watercooled) RAM: 32GB 3600Mhz Corsair LPX MB: Gigabyte B550i PSU: Corsair SF750 Case: Hyte Revolt 3

 

Link to post
Share on other sites

the db behind it is not for me to change and i also didnt design it. i also am very confused and sometimes angry because he stored everything like this. also he didnt use foreign keys or any relations whatsoever. there are no constraints. this db is a mess but i gots to work with it and make the best with what i have ..... oh and kill the original designer obviously

you get to be the violent psychopath this time around, rightfully so

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×