Alicia Posted November 23, 2009 Share Posted November 23, 2009 Hi, May I know how can I get a proper query for this requirement : SELECT * FROM Table WHERE columnA = 1 AND columnB =($A || $B || $C || $D ) $A,$B,$C and $D are values posted by user. If any of those variables have nothing inside/no value, it will not be included in the query. E.g : If $(c == "") . the query will be *SELECT * FROM Table WHERE columnA = 1 AND columnB =($A || $B || $D ) I tried conditional statement to accomplish this but failed. Some guru please advise on this. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/182601-query-issue/ Share on other sites More sharing options...
kickstart Posted November 23, 2009 Share Posted November 23, 2009 Hi Think what you are thinking of is SELECT * FROM Table WHERE columnA = 1 AND columnB IN ($A,$B,$C,$D ) or if text fields SELECT * FROM Table WHERE columnA = 1 AND columnB IN ('$A','$B','$C','$D' ) All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/182601-query-issue/#findComment-963829 Share on other sites More sharing options...
Alicia Posted November 23, 2009 Author Share Posted November 23, 2009 An error displayed : #1271 - Illegal mix of collations for operation ' IN ' SELECT * FROM cd WHERE week IN ('Te','Tev','Yed') Please advise. Quote Link to comment https://forums.phpfreaks.com/topic/182601-query-issue/#findComment-963891 Share on other sites More sharing options...
kickstart Posted November 23, 2009 Share Posted November 23, 2009 Hi Not sure. A quick google suggests the problem is down to a mismatch between the collation type of the data you are using and that which the column is declared with. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/182601-query-issue/#findComment-963901 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.