justmelat
asked on
is this the correct syntax for my sql/php statement
i have a table that will have a lot of empty fields that i want to exclude from my query.
is this the correct syntax
$sql .= " Select * FROM REQUEST WHERE R_STATUS = 'S' and R_GTM_LAUNCH='No' and (!isnull(R_GTM_LAUNCH) ORDER BY R_NUMBER DESC";
is this the correct syntax
$sql .= " Select * FROM REQUEST WHERE R_STATUS = 'S' and R_GTM_LAUNCH='No' and (!isnull(R_GTM_LAUNCH) ORDER BY R_NUMBER DESC";
>>a lot of empty fields
If you are trying to avoid the fields that you will get from the *, then you need to check each field individually via (fieldname IS NOT NULL):
$sql .= " Select * FROM REQUEST WHERE R_STATUS = 'S' and R_GTM_LAUNCH='No' and (`field1` IS NOT NULL) and (`field2` IS NOT NULL) ORDER BY
If you are trying to avoid the fields that you will get from the *, then you need to check each field individually via (fieldname IS NOT NULL):
$sql .= " Select * FROM REQUEST WHERE R_STATUS = 'S' and R_GTM_LAUNCH='No' and (`field1` IS NOT NULL) and (`field2` IS NOT NULL) ORDER BY
ASKER
Hielo
we are change the db, so now the launch field will always have a value, before it was sometimes empty/null, so in my query I want it to ignore the time when launch is empty.
we are change the db, so now the launch field will always have a value, before it was sometimes empty/null, so in my query I want it to ignore the time when launch is empty.
$sql .= " Select * FROM REQUEST WHERE R_STATUS = 'S' and (R_GTM_LAUNCH IS NOT NULL)
ASKER
Hielo,
it's still grabbing the empty fields. Is !empty and option?
it's still grabbing the empty fields. Is !empty and option?
>> Is !empty and option?
No. there is no such function in MySQL.
You probably have some fields set to an empty string, and others set to NULL. Try:
$sql .= " Select * FROM REQUEST WHERE R_STATUS = 'S' and (''<>R_GTM_LAUNCH) AND (R_GTM_LAUNCH IS NOT NULL)
No. there is no such function in MySQL.
You probably have some fields set to an empty string, and others set to NULL. Try:
$sql .= " Select * FROM REQUEST WHERE R_STATUS = 'S' and (''<>R_GTM_LAUNCH) AND (R_GTM_LAUNCH IS NOT NULL)
ASKER
I just realized what you were saying at first the null values shouldn't appear any way because they don't equal no
i have to be doing something else wrongl.
i have to be doing something else wrongl.
ASKER
did you mean to have the "<>? I've never seend that used in a query like this
(''<>R_GTM_LAUNCH)
(''<>R_GTM_LAUNCH)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's Hielo, you rock! as always. Thanks.
$sql .= " Select * FROM `REQUEST` WHERE `R_STATUS` = 'S' and `R_GTM_LAUNCH`='No' ORDER BY R_NUMBER DESC";