This is a discussion on Special query with multiples fields within the MySQL Database forums, part of the Database Forums category; Hello, (And sorry for my english, caus' I'm french) I've got a problem with a MySql query : SELECT * ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello, (And sorry for my english, caus' I'm french)
I've got a problem with a MySql query : SELECT * FROM table1 as t1 WHERE (t1.field1,t1.field2,t1.field3) IN ('a','b','c'), ('d','e','f'), ('g','h','i') This query isn't ok, but I don't know hox to deal with this.. I want to get every lines where field1 AND field2 AND field3 is in one of the triplet I've got... ie: If the line (a,b,c) is in my table, I want to get it, but if the line is only (a,b,d), I Don't want to get it.. Perharps someone should help me to do this ? Thanks, Regards. And sorry again for my very bad english... Yttrium |
|
|||
|
On 15.01.2007 16:42, Yttrium wrote:
> I've got a problem with a MySql query : > > SELECT * > FROM table1 as t1 > WHERE (t1.field1,t1.field2,t1.field3) > IN ('a','b','c'), ('d','e','f'), ('g','h','i') > > This query isn't ok, but I don't know hox to deal with this.. > I want to get every lines where field1 AND field2 AND field3 is in one > of the triplet I've got... > > ie: > If the line (a,b,c) is in my table, I want to get it, but if the line is > only (a,b,d), I Don't want to get it.. > > Perharps someone should help me to do this ? You have to explicitely formulate your condition .... where ( t1.field1 = 'a' and t1.field2 = 'b' and ... ) or ( t1.field1 = ... and ... ) There is no other efficient way AFAIK. Greetings from old Europe to old Europe ;-) robert |
|
|||
|
In article <45aba0db$0$5091$ba4acef3@news.orange.fr>,
Yttrium <POUSSIERES.ngtrash@gmail.com> writes: > Hello, (And sorry for my english, caus' I'm french) > I've got a problem with a MySql query : > SELECT * > FROM table1 as t1 > WHERE (t1.field1,t1.field2,t1.field3) > IN ('a','b','c'), ('d','e','f'), ('g','h','i') The last line is wrong. Make that IN (('a','b','c'), ('d','e','f'), ('g','h','i')) |
|
|||
|
Yttrium wrote: > Hello, (And sorry for my english, caus' I'm french) > > I've got a problem with a MySql query : > > SELECT * > FROM table1 as t1 > WHERE (t1.field1,t1.field2,t1.field3) > IN ('a','b','c'), ('d','e','f'), ('g','h','i') > > This query isn't ok, but I don't know hox to deal with this.. > I want to get every lines where field1 AND field2 AND field3 is in one > of the triplet I've got... > > ie: > If the line (a,b,c) is in my table, I want to get it, but if the line is > only (a,b,d), I Don't want to get it.. > > Perharps someone should help me to do this ? > > Thanks, Regards. > > And sorry again for my very bad english... > > Yttrium What precisely you do here depends on what the real data looks like, you may wish to substitute CONCAT_WS for CONCAT and use a separater between the individual data items in the query below: SELECT * FROM table1 as t1 WHERE CONCAT(t1.field1,t1.field2,t1.field3) IN ('abc', 'def', 'ghi') |
|
|||
|
> SELECT *
> FROM table1 as t1 > WHERE (t1.field1,t1.field2,t1.field3) > IN ('a','b','c'), ('d','e','f'), ('g','h','i') I don't think this syntax can be used with SELECT, but the HANDLER statement can do it. -- Willem Bogaerts Application smith Kratz B.V. http://www.kratz.nl/ |
|
|||
|
Le 15/01/2007 17:10, Willem Bogaerts nous disait:
>> SELECT * >> FROM table1 as t1 >> WHERE (t1.field1,t1.field2,t1.field3) >> IN ('a','b','c'), ('d','e','f'), ('g','h','i') > > I don't think this syntax can be used with SELECT, but the HANDLER > statement can do it. > What does it means exactly ? -- [- Yttrium -] Jetez un oeil à http://www.danstesyeux.com |
|
|||
|
>>> SELECT *
>>> FROM table1 as t1 >>> WHERE (t1.field1,t1.field2,t1.field3) >>> IN ('a','b','c'), ('d','e','f'), ('g','h','i') >> >> I don't think this syntax can be used with SELECT, but the HANDLER >> statement can do it. >> > > What does it means exactly ? > http://dev.mysql.com/doc/refman/4.1/en/handler.html Seems you can't do it in one go though. Best bet is the SELECT with conditions. Best regards -- Willem Bogaerts Application smith Kratz B.V. http://www.kratz.nl/ |
![]() |
| Thread Tools | |
| Display Modes | |
|
|