Gossamer Forum
Home : General : Databases and SQL :

select query

Quote Reply
select query
Dear all,

I have a table with eight columns.
My selection is majorly based on 2 feilds called LS and CODE (none of them are uniq).

select * from mytable where LS in (10,20,30,40) ...

but I want the result only for those CODES which have 'all' the LS mentioned here ie., 10,20,30 an 40.

How can I do this.

Hope my question is clear.

Thanks in advance.

Best

Thangudu
Quote Reply
Re: [thangudu] select query In reply to
Please use the correct forum. I've moved your thread into a more approriate category for you.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [thangudu] select query In reply to
select * from mytable

where FIND_IN_SET('10',LS)

AND FIND_IN_SET('20',LS)

AND FIND_IN_SET('30',LS)

AND FIND_IN_SET('40',LS)



There could be a way to combine them into one find_in_set, I haven`t tried.

chmod
Quote Reply
Re: [chmod] select query In reply to
I put my question another way

my table looks like this :
code size
1n3j 14
1n3j 32
1n3j 37
1n9j 14
1n9j 32
1n9j 14
1nm4 14
1nm4 37
1nm4 32
1nmi 14
1nmi 14
1oo3 14
1oo3 14
1oo4 14
1oo4 14

I want to select those rows with 'size' 14, 32 and 37. This is easy..but I
also want only those uniq codes which have all the 'size' (14,32 and 37)
associated with it. Please note that none of the feilds are uniq.
Here in this case I want result like

1n3j 14
1n3j 32
1n3j 37
1nm4 14
1nm4 37
1nm4 32

because 1n3j and 1nm4 are the only two codes which have all the 'size's
requested ie., 14,32, 37.

Hope my question is clear.

Any kind of help is highly appreciated.

Best

Rajesh
Quote Reply
Re: [thangudu] select query In reply to
Hey,

I answered you question on your other post. Check you answer there. Hope that answer is helpful.

Thanks.