SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    FIND_IN_SET syntax problem

    hi there, hope in your help.
    1. if tried the query #1 I have for output 22 rows in set
    2. if tried the query #2 I have for output 16 rows in set

    Why?
    Where does the row with output null ?
    thank you.

    query #1
    Code:
    mysql> SELECT
    	ID,
    	output
    FROM
    	tbl_0
    WHERE
    	1
    AND ID IN (
    	492,
    	852,
    	2713,
    	4159,
    	4498,
    	5258,
    	5477,
    	5594,
    	5760,
    	6404,
    	6419,
    	8305,
    	8816,
    	9863,
    	10363,
    	10401,
    	10448,
    	10449,
    	10450,
    	11138,
    	11201,
    	11301
    );
    +-------+--------+
    | ID    | output |
    +-------+--------+
    |   492 |        |
    |   852 | 01     |
    |  2713 | 01     |
    |  4159 | 01     |
    |  4498 |        |
    |  5258 | 01     |
    |  5477 | 01     |
    |  5594 | 01     |
    |  5760 |        |
    |  6404 |        |
    |  6419 |        |
    |  8305 | 01     |
    |  8816 | 01     |
    |  9863 | 01     |
    | 10363 | 01     |
    | 10401 | 01     |
    | 10448 | 01     |
    | 10449 | 01     |
    | 10450 | 01     |
    | 11138 | 01     |
    | 11201 | 01     |
    | 11301 |        |
    +-------+--------+
    22 rows in set
    query #2
    Code:
    mysql> SELECT
    	ID,
    	output
    FROM
    	tbl_0
    WHERE
    	FIND_IN_SET('01', output) > 0
    OR FIND_IN_SET('02', output) > 0
    OR FIND_IN_SET('03', output) > 0
    OR FIND_IN_SET('04', output) > 0
    OR FIND_IN_SET('', output) > 0
    OR FIND_IN_SET(NULL, output) > 0
    OR ISNULL(output)
    OR output IS NULL
    ORDER BY
    	ID ASC;
    +-------+--------+
    | ID    | output |
    +-------+--------+
    |   852 | 01     |
    |  2713 | 01     |
    |  4159 | 01     |
    |  5258 | 01     |
    |  5477 | 01     |
    |  5594 | 01     |
    |  8305 | 01     |
    |  8816 | 01     |
    |  9863 | 01     |
    | 10363 | 01     |
    | 10401 | 01     |
    | 10448 | 01     |
    | 10449 | 01     |
    | 10450 | 01     |
    | 11138 | 01     |
    | 11201 | 01     |
    +-------+--------+
    16 rows in set
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,338
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    why are you using FIND_IN_SET at all?

    the column "output" does not contain a set
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thank you, I understand.
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye


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
  •