Professional Web Applications Themes

Special query with multiples fields - MySQL

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, ...

  1. #1

    Default Special query with multiples fields

    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
    Yttrium Guest

  2. #2

    Default Re: Special query with multiples fields

    On 15.01.2007 16:42, Yttrium wrote: 

    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
    Robert Guest

  3. #3

    Default Re: Special query with multiples fields

    In article <45aba0db$0$5091$orange.fr>,
    Yttrium <com> writes:
     
     

    The last line is wrong. Make that
    IN (('a','b','c'), ('d','e','f'), ('g','h','i'))
    Harald Guest

  4. #4

    Default Re: Special query with multiples fields


    Yttrium wrote:
     

    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')

    Captain Guest

  5. #5

    Default Re: Special query with multiples fields

    > SELECT * 

    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/
    Willem Guest

  6. #6

    Default Re: Special query with multiples fields

    Le 15/01/2007 17:10, Willem Bogaerts nous disait: 
    >
    > I don't think this syntax can be used with SELECT, but the HANDLER
    > statement can do it.
    >[/ref]

    What does it means exactly ?

    --
    [- Yttrium -]
    Jetez un oeil http://www.danstesyeux.com
    Yttrium Guest

  7. #7

    Default Re: Special query with multiples fields

    >>> SELECT * 
    >>
    >> I don't think this syntax can be used with SELECT, but the HANDLER
    >> statement can do it.
    >>[/ref]
    >
    > What does it means exactly ?
    >[/ref]

    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/
    Willem Guest

  8. #8

    Default Re: Special query with multiples fields


    Willem Bogaerts wrote: 

    My suggested query does it in one go!

    Captain Guest

Similar Threads

  1. HTML form fields and special characters
    By Alen in forum Coldfusion - Advanced Techniques
    Replies: 3
    Last Post: May 31st, 09:23 PM
  2. CAML Query: Multiple Query Fields Issue
    By Jon F. in forum ASP.NET Web Services
    Replies: 0
    Last Post: May 12th, 08:19 PM
  3. Replies: 5
    Last Post: September 17th, 09:27 PM
  4. Replies: 0
    Last Post: September 15th, 04:33 PM
  5. Special Characters in passed Query String
    By Sunshine Valdes in forum ASP
    Replies: 2
    Last Post: September 11th, 10:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139