 | | | | |  | | | | | Guest | Special query with multiples fields -
06-04-2007, 07:47 AM
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 | | | | | | | | Guest | Re: Special query with multiples fields -
06-04-2007, 07:47 AM
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 | | | | | | | | Guest | Re: Special query with multiples fields -
06-04-2007, 07:47 AM
In article <45aba0db$0$5091$EMAIL REMOVED>,
Yttrium <EMAIL REMOVED> 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')) | | | | | | | | Guest | Re: Special query with multiples fields -
06-04-2007, 07:47 AM
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') | | | | | | | | Guest | Re: Special query with multiples fields -
06-04-2007, 07:47 AM
> 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/ | | | | | | | | Guest | Re: Special query with multiples fields -
06-04-2007, 07:47 AM
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 | | | | | | | | Guest | Re: Special query with multiples fields -
06-04-2007, 07:47 AM
>>> 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/ | | | | | | | | Guest | Re: Special query with multiples fields -
06-04-2007, 07:48 AM
Willem Bogaerts wrote:
> Seems you can't do it in one go though. Best bet is the SELECT with
> conditions.
My suggested query does it in one go! | | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |  |