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 > SELECT statement doesnt work

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-08-04, 02:52
ONIL ONIL is offline
Registered User
 
Join Date: Feb 2004
Posts: 14
Red face SELECT statement doesnt work

hi

the following SELECT statement doesnt work. a error msg : - Query input must contain at least one table or query. (Error 3067)
is promted . can u explain or suggest a way around


For N = 1 To N = 255 Step 1
CQ = " SELECT * FROM TELEPHONE_DIRECTORY" & _
" WHERE LEFT(LAST_NAME,N)LIKE [something1] " & _
" ORDER BY LAST_NAME; "
Next N
Reply With Quote
  #2 (permalink)  
Old 02-08-04, 06:42
stadian stadian is offline
Registered User
 
Join Date: Jan 2004
Location: BC - It's the place to be.
Posts: 13
Re: SELECT statement doesnt work

Quote:
Originally posted by ONIL
the following SELECT statement doesnt work. a error msg : - Query input must contain at least one table or query. (Error 3067)

For N = 1 To N = 255 Step 1
CQ = " SELECT * FROM TELEPHONE_DIRECTORY" & _
" WHERE LEFT(LAST_NAME,N)LIKE [something1] " & _
" ORDER BY LAST_NAME; "
Next N
I ran that query in a sample database and it worked fine as it is, however I'm not too sure about your N index as you did not explain much what you are trying to do.

But basically, make sure that the table TELEPHONE_DIRECTORY does exist or that the spelling is correct and that it can be "seen" through your connection.

Other than that, we need to know more details if you can spare them.

Ref: select * from <table> where left(<field>,index) like (<condition>) order by <field>

is ok in itself.

I hope others can help you more.
Reply With Quote
  #3 (permalink)  
Old 02-08-04, 06:55
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
As "N" has been declared a LOOP variable, the following code is required,

"WHERE LEFT(LAST_NAME,"& N &")"

If the code "LEFT(LAST_NAME, N)" is passed to Access as an SQL Query, the user will be prompted for the value of "N" providing there is no column named "N".
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Last edited by r123456; 02-08-04 at 07:10.
Reply With Quote
  #4 (permalink)  
Old 02-08-04, 08:38
ONIL ONIL is offline
Registered User
 
Join Date: Feb 2004
Posts: 14
Re: SELECT statement doesnt work

hi

thanks for helping. when the for N= 1 to N= 255 is removed and in the syntax N is replaced with a numerical the select statement works prefectly

other details are as follows: -

For N = 1 To N = 255 Step 1
CQ.SQL = "PARAMETERS something1 STRING; SELECT * FROM TELEPHONE_DIRECTORY" & _
" WHERE LEFT(LAST_NAME," & N & ")LIKE [something1] " & _
" ORDER BY LAST_NAME; "
Next N

' THE FOLLOWING ALSO DOES NOT WORK !?!?!?!?!?
' IT POPULATES THE LIST BOX WITH ALL RECORDS
' CQ.SQL = "PARAMETERS something1 STRING; SELECT * FROM TELEPHONE_DIRECTORY" & _
' " WHERE LAST_NAME LIKE '[something1]' " & _
' " ORDER BY EXTENSION_No; "

Quote:
Originally posted by stadian
I ran that query in a sample database and it worked fine as it is, however I'm not too sure about your N index as you did not explain much what you are trying to do.

But basically, make sure that the table TELEPHONE_DIRECTORY does exist or that the spelling is correct and that it can be "seen" through your connection.

Other than that, we need to know more details if you can spare them.

Ref: select * from <table> where left(<field>,index) like (<condition>) order by <field>

is ok in itself.

I hope others can help you more.
Reply With Quote
  #5 (permalink)  
Old 02-08-04, 08:41
ONIL ONIL is offline
Registered User
 
Join Date: Feb 2004
Posts: 14
hi thanks for the help but it did not work


also kindly look at this issue too
' THE FOLLOWING ALSO DOES NOT WORK !?!?!?!?!?
' IT POPULATES THE LIST BOX WITH ALL RECORDS
' CQ.SQL = "PARAMETERS something1 STRING; SELECT * FROM TELEPHONE_DIRECTORY" & _
' " WHERE LAST_NAME LIKE '[something1]' " & _
' " ORDER BY EXTENSION_No; " ' inserting * or % also doesn't help

Quote:
Originally posted by r123456
As "N" has been declared a LOOP variable, the following code is required,

"WHERE LEFT(LAST_NAME,"& N &")"

If the code "LEFT(LAST_NAME, N)" is passed to Access as an SQL Query, the user will be prompted for the value of "N" providing there is no column named "N".
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