This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Selecting multiple values in a column

Tags: None
(comma "," separated)
User avatar
iwhitfield
Registered Member
Posts
33
Karma
0
OS

Selecting multiple values in a column

Mon Jan 23, 2017 11:11 am
Hi All
Can anyone give me the correct syntax for selecting multiple values from a single column in a table please.
I have Googled for it but can get nothing to work!!
I have a field in my Database called 'StatusText' that can have one of several values.
I can select for one value but what is the Syntax for multiple values?

IE what I want is something like this -
Code: Select all
SELECT *, preffirstname, surname, statustext FROM members WHERE members.statustext = 'ACTIVE' OR 'PENDING' OR JOINT'

But this (and other variations) just gives me errors.

Thanks for any help.
User avatar
jstaniek
Moderator
Posts
1027
Karma
2
OS
Hi Ian.
For example:
SELECT *, preffirstname, surname, statustext FROM members WHERE members.statustext = 'ACTIVE' OR members.statustext = 'PENDING' OR members.statustext = 'JOINT'

Notes for your query:
- "preffirstname, surname, statustext" is redundant after "*" isn't it?
- conditions can be simplified using aliases: SELECT *, members.statustext AS s FROM members WHERE s = 'ACTIVE' OR s = 'PENDING' OR s = 'JOINT'
- "members.statustext IN (.., .., ..)" would be possible in future Kexi.


Best regards,
Jarosław Staniek
• Qt Certified Specialist
KEXI - Open Source Visual DB Apps Builder
• Request a feature or fix for KEXI here
May I help you? Please mention your app's version and OS when asking for help
User avatar
iwhitfield
Registered Member
Posts
33
Karma
0
OS
Thanks Jaslaw
That worked perfectly!!
User avatar
jstaniek
Moderator
Posts
1027
Karma
2
OS
Good, in such cases could you please click "Accept this answer" above? Thanks.


Best regards,
Jarosław Staniek
• Qt Certified Specialist
KEXI - Open Source Visual DB Apps Builder
• Request a feature or fix for KEXI here
May I help you? Please mention your app's version and OS when asking for help


Bookmarks



Who is online

Registered users: Bing [Bot], gfielding, Google [Bot], markhm, sethaaaa, Sogou [Bot], Yahoo [Bot]