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 > Data Access, Manipulation & Batch Languages > ANSI SQL > Another n00b select statement problem...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-15-04, 05:59
piatan piatan is offline
Registered User
 
Join Date: Mar 2004
Location: Washington State
Posts: 2
Another n00b select statement problem...

When I try to use this select statement:

SELECT main.title, main.URL, main.description, main.city FROM main ORDER BY city WHERE (((main.active)=True));

I get a: Syntax error (missing operator) in query expression 'city WHERE (((main.active)=True))'

But, if I try this:

SELECT main.title, main.URL, main.description, main.city FROM main WHERE (((main.active)=True));

or this:

SELECT main.title, main.URL, main.description, main.city FROM main ORDER BY city;

They both work as expected. How do I combine them effectively?




Also, when I try the select statement below:

SELECT main.title, main.url, main.description, main.city
FROM main
WHERE (((main.category)="educ") AND ((main.category_2)="elem") AND ((main.active)=True));

I get a: Unterminated string constant Error (probably because of the double quotes?)

So how can this one be formatted to work without the quotes? (I have tried just removing them to no avail)


Thank You for your help. I am very happy to have found this resource (even though I couldn't find a thread with a solution to a similar problem)
Reply With Quote
  #2 (permalink)  
Old 03-15-04, 06:13
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
for your first problem, ORDER BY must follow WHERE

for your second problem the string delimiter is the single quote, not the double quote
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-15-04, 06:25
piatan piatan is offline
Registered User
 
Join Date: Mar 2004
Location: Washington State
Posts: 2
Quote:
Originally posted by r937
for your first problem, ORDER BY must follow WHERE

for your second problem the string delimiter is the single quote, not the double quote
Thank you, first problem solved (Order of operations did the trick)

However, the second problem remains:

rs.Open "SELECT main.title, main.url, main.description, main.city
FROM main
WHERE (((main.category_2)='elem'));", conn%>

When you said the string delimiter is the single quote, I am assuming that means to bracket the elem by single quotes instead of double. The above select statement still gives me a Unterminated string constant error.
Reply With Quote
  #4 (permalink)  
Old 03-15-04, 07:03
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 03-15-04, 07:34
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Could this be because you are using VBScript which requires end of line continuation markers something more like this? :-

rs.Open "SELECT main.title, main.url, main.description, main.city" _
& " FROM main" _
& " WHERE (((main.category_2)='elem'));", conn%>
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
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