Forums

This topic is locked

sql query

Posted 21 Dec 2004 17:46:26
1
has voted
21 Dec 2004 17:46:26 Chris Trace posted:
Hello,

Am trying to write a sql query to search using three possible input fields.

sql statement reads

SELECT *
FROM institutiondata
WHERE insitutionid = 'institutionid' OR institutionname = 'institutionname' OR institutionstate = 'institutionstate'

variables set out thusly

default %
run time #institutionid#

etc

when tested the error reads

1064 sql statement syntax for %=%

is this a closed loop error and if so what do i put in the default value field.

thanks

Replies

Replied 26 Dec 2004 11:05:54
26 Dec 2004 11:05:54 Chris Charlton replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Am trying to write a sql query to search using three possible input fields.

sql statement reads

SELECT *
FROM institutiondata
WHERE insitutionid = 'institutionid' OR institutionname = 'institutionname' OR institutionstate = 'institutionstate'<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Personally, I'd not use the same names as the column names (ie. insitutionid = 'institutionid'), maybe more like a <i>insitutionid = 'inst_id'</i> or something like that. There may or may not be a conflict.

~~~~~~~~~~~~~~~
Chris Charlton

Sr. Developer - www.fingerprintMedia.com
Replied 30 Dec 2004 20:20:16
30 Dec 2004 20:20:16 Daniel Severns replied:
Trace,
I would also suggest something like what Charlton suggested. Additionaly, it would be a more efficent query if you specify the actual column you want to pull data from.

Try:

SELECT intData.institutionID, intData.SecondColumn, intData.thirdcolumn
FROM institutiondata AS intData
WHERE intData.institutionID="institutionid" OR intData.institutionID="institutionstate" OR intData.institutionID="institutionname"

Let us know how it turns out.
Daniel <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Replied 27 Apr 2005 07:34:14
27 Apr 2005 07:34:14 Chris Trace replied:
daniel the last one worked with a few tweaks thanks

Reply to this topic