Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2005
    Posts
    8

    Unanswered: MYSQL SELECT question

    I have this statement

    SELECT *FROM `data`WHERE `symbol` = 'PUB1'

    how do i modify this statement to also select PUB2 and PUB6 ?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    SELECT *FROM data WHERE symbol in ("PUB1", "PUB2"...."Pubn");
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2005
    Posts
    8
    Quote Originally Posted by healdem
    SELECT *FROM data WHERE symbol in ("PUB1", "PUB2"...."Pubn");
    yes it works thanks very much

  4. #4
    Join Date
    Jun 2005
    Posts
    8
    I also have this situation with two tables

    SELECT *FROM data WHERE symbol in ("PUB1", "PUB2"...."Pubn");
    SELECT *FROM basket WHERE symbol in ("PUB1", "PUB2"...."Pubn");

    is it possible to select to combine both tables ordered by symbol for the symbols ("PUB1", "PUB2"...."Pubn")

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    theoretically I don't see why not

    if your join is correct..
    SELECT *FROM data join basket on data.Symbol=basket.symbol WHERE symbol in ("PUB1", "PUB2","PUB3");
    give it a whirl and see what happens
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    Code:
    SELECT *FROM data join basket on data.Symbol=basket.symbol WHERE symbol in ("PUB1", "PUB2","PUB3")
    Regarding "symbol in...", isn't that "symbol" ambiguous?

    Gatta run, but simplest thing I think would be a UNION, no?

  7. #7
    Join Date
    Jun 2005
    Posts
    8
    yes it came back with this

    #1052 - Column: 'symbol' in where clause is ambiguous

    i don't know how to write it using union, i found replacing join with union does'nt work
    Last edited by harper; 01-26-06 at 19:34.

  8. #8
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    Code:
    SELECT * FROM data WHERE symbol in ("PUB1", "PUB2"...."Pubn")
    UNION
    SELECT * FROM basket WHERE symbol in ("PUB1", "PUB2"...."Pubn")
    Make sure the two queries return the same columns though.

Posting Permissions

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