matthew_moore_2 Posted December 20, 2008 Share Posted December 20, 2008 How can I write a SQL statement that returns all columns in table A, one that returns all columns in table A where inv is 1, and a statement that returns all columns from table A and B where inv is equal? I don't know that much about writing statements Quote Link to comment https://forums.phpfreaks.com/topic/137862-basic-select-statements/ Share on other sites More sharing options...
ngreenwood6 Posted December 20, 2008 Share Posted December 20, 2008 You would need to make 2 different queries and then figure out which one you need. if($inv == 1) { $query = "SELECT * FROM table WHERE a='value'"; } else { $query = "SELECT * FROM table WHERE a='value' AND b='value'"; } Quote Link to comment https://forums.phpfreaks.com/topic/137862-basic-select-statements/#findComment-720519 Share on other sites More sharing options...
matthew_moore_2 Posted December 21, 2008 Author Share Posted December 21, 2008 So just modify this statement to reflect the other two? Quote Link to comment https://forums.phpfreaks.com/topic/137862-basic-select-statements/#findComment-720527 Share on other sites More sharing options...
ngreenwood6 Posted December 21, 2008 Share Posted December 21, 2008 That was just a basic example of how you can accomplish what you are trying to accomplish but yeah basically you can just modify it for your needs substituting what you need where you need it. once you get something down and have a problem getting it to work come back and post. Quote Link to comment https://forums.phpfreaks.com/topic/137862-basic-select-statements/#findComment-720562 Share on other sites More sharing options...
fenway Posted December 22, 2008 Share Posted December 22, 2008 How can I write a SQL statement that returns all columns in table A, one that returns all columns in table A where inv is 1, and a statement that returns all columns from table A and B where inv is equal? I have no idea what you're getting at. Quote Link to comment https://forums.phpfreaks.com/topic/137862-basic-select-statements/#findComment-721575 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.