
Wildcard SQL statement
Good afternoon. I need some help with my wildcard search. I am trying to write the SQL statement so that my users can specify text that they want to search on that can appear anywhere within the specified field. However, I am getting a syntax error stating I am missing a () and I can't quite figure this out. Does anything look odd to you? Here's my SQL statement:<BR><BR><BR> sql = "SELECT [Circ Dtls].Circuit, [Circ Dtls].USOC, [Circ Dtls].[Class of Service], [Circ Dtls].Dept, [Circ Dtls].[Local Carrier], [Circ Dtls].[LD Dept], [Circ Dtls].[LD Carrier], [Circ Dtls].[Picc Date], [Circ Dtls].Amount, [Circ Dtls].[Site ID 1], [Circ Dtls].[Site ID 2], [Circ Dtls].Disconnected, [Circ Dtls].[Date Disconnected], [Circ Dtls].[Ordered By], [Circ Dtls].Confirmed, [Circ Dtls].Critical, [Circ Dtls].[Critical Description], [Circ Dtls].Comments FROM [Circ Dtls] WHERE ((([Circ Dtls].Circuit Like'%%'" & Request.QueryString("circuit_w:") & _<BR>" ORDER BY [Circ Dtls].Circuit "

RE: Wildcard SQL statement
... FROM [Circ Dtls] WHERE ([Circ Dtls].Circuit Like'% " & Request.QueryString("circuit_w:") & "%' ORDER BY [Circ Dtls].Circuit

RE: Wildcard SQL statement
I dont actually think you need so many paranthesis after where clause.. and I guess you need that querystring go within % and %.<BR>Assuming what I thought was correct,<BR>Try this:<BR>SQL = "SELECT [Circ Dtls].Circuit, [Circ Dtls].USOC, [Circ Dtls].[Class of Service], [Circ Dtls].Dept, [Circ Dtls].[Local Carrier], [Circ Dtls].[LD Dept], [Circ Dtls].[LD Carrier], [Circ Dtls].[Picc Date], [Circ Dtls].Amount, [Circ Dtls].[Site ID 1], [Circ Dtls].[Site ID 2], [Circ Dtls].Disconnected, [Circ Dtls].[Date Disconnected], [Circ Dtls].[Ordered By], [Circ Dtls].Confirmed, [Circ Dtls].Critical, " & _<BR> "[Circ Dtls].[Critical Description], [Circ Dtls].Comments " & _<BR> "FROM [Circ Dtls] " & _<BR> "WHERE [Circ Dtls].[Circuit] Like '%" & Request.QueryString("circuit_w:") & "%' " & _<BR> "ORDER BY [Circ Dtls].Circuit "

RE: Wildcard SQL statement
That was it!!!! Thanks so much. I see where I made my mistake. I guess I had too much tunnel vision because the error I kept getting was that I was missing an operator (). I didn't even think about the fact that I could have had too many. I feel so stupid now. Thanks a lot for your help.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

