If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MYSQL SELECT question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-06, 16:38
harper harper is offline
Registered User
 
Join Date: Jun 2005
Posts: 8
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 ?
Reply With Quote
  #2 (permalink)  
Old 01-24-06, 02:56
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,258
SELECT *FROM data WHERE symbol in ("PUB1", "PUB2"...."Pubn");
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 01-24-06, 13:20
harper harper is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 01-24-06, 16:52
harper harper is offline
Registered User
 
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")
Reply With Quote
  #5 (permalink)  
Old 01-24-06, 18:01
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,258
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #6 (permalink)  
Old 01-24-06, 18:48
jfulton jfulton is offline
Registered User
 
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?
Reply With Quote
  #7 (permalink)  
Old 01-26-06, 18:22
harper harper is offline
Registered User
 
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 18:34.
Reply With Quote
  #8 (permalink)  
Old 01-28-06, 17:14
jfulton jfulton is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On