ASP/SQL Syntax Brain FART!

  • Thread starter Andrew J Durstewitz
  • Start date
A

Andrew J Durstewitz

Hey, could someone remind me how to do this?

I want to select a client from TABLE1 where their sub_id is equal to 'O'
or 1?

For some reason I forgot how to do this in one statement.

Thanks,
Andrew J Durstewitz
http://www.devbuilder.org

DEVBuilder.org, http://www.DEVBuilder.org
ASP,ASP.NET,VB.NET,PHP,Java,and SQL Support, all in one place.
 
A

Aaron Bertrand - MVP

What datatype is sub_id? How can it possibly be an 'O' or a 1?

Anyway, you can use an OR clause, like

WHERE sub_id=0 OR sub_id=1

Or you could use an IN list, like

WHERE sub_id IN ('O', 'something')
 
D

Dan Brussee

Hey, could someone remind me how to do this?

I want to select a client from TABLE1 where their sub_id is equal to 'O'
or 1?

For some reason I forgot how to do this in one statement.

select xxx from Table1 Where sub_id = 0 or sub_id = 1


or


select xxx from Table1 where sub_id in (0, 1)
 
A

Andrew J Durstewitz

I understand the OR statement but I need to it to be a match of 2 or 3
items.

client MUST = strClient
sub_id MUST = 'O' or 1

See what I mean?

Something like...

Select * from TABLE1 where client = strClient and (sub_id = 'O' or
sub_id = 1)

I think that's the wrong syntax, that is why I am having a problem.

thx,
Andrew

DEVBuilder.org, http://www.DEVBuilder.org
ASP,ASP.NET,VB.NET,PHP,Java,and SQL Support, all in one place.
 
T

Tom B

I don't think you said that in your first post.
Did you try the statement you posted? It looks like what you want except
the 1 should be in quotes (as I assume sub_id is a char or varchar)
"SELECT client, sub_id FROM client WHERE (client='" & strClient & "') AND
(sub_id='O' OR sub_id='1')"

I added the paranthesis for clarity.
 
M

Mike

Why do you think it is the wrong syntax? Show some data and desired
results.


Is sub_id a text field or numeric? You are trying to select either text or
numeric from a field which is it?

Select * from TABLE1 where client = strClient and (sub_id = 0 or
sub_id = 1)

or


Select * from TABLE1 where client = strClient and (sub_id = 'O' or
sub_id = '1')


Mike
 
A

Andrew J Durstewitz

Thanks guys, it's working now. Just had some syntax errors on my side
it looks.

Thank you,
Andrew

DEVBuilder.org, http://www.DEVBuilder.org
ASP,ASP.NET,VB.NET,PHP,Java,and SQL Support, all in one place.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top