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. 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 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. 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 Link to comment https://forums.phpfreaks.com/topic/182601-query-issue/#findComment-963901 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.