Link to home
Start Free TrialLog in
Avatar of Aidam-Unlimited
Aidam-UnlimitedFlag for United Kingdom of Great Britain and Northern Ireland

asked on

[MySQL+PHP] SELECT -> Ignore condition if zero rows?

Hi,

I have this example mysql_query:

mysql_query("SELECT * FROM table WHERE id='$id' AND name NOT IN($names)");

Is there any option in mysql_query to get results even if this returns Zero rows, i.e. run query ignoring that second condition?

I know it's easy to use PHP if() but I'm just curious whether is possible to do it inside one mysql_query.

Thanks for ideas!
SOLUTION
Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aidam-Unlimited

ASKER

Thanks to both of you guys!