SQL compare to form value -HELP-
I am trying to test whether or not 3 SQL fields are equal to a form field. I am doing this within an SQL method. (I am trying to learn zope and Mysql at the sam time) How does one do this? Here is where I am going with this so far: I have these listed as arguments: Breeds Breed1 Breed2 Breed3 SELECT * from Ranch WHERE Breeds = <dtml-sqltest name="Breed1" type="string"> OR Breeds = <dtml-sqltest name="Breed2" type="string"> or Breeds = <dtml-sqltest name="Breed3" type="string"> Breeds is the name of the form input and I want to test and see if it equals any one of the 3 fields Breed1, Breed2, or Breed3 and return all of the row if there is a match. -- Sean
This was not a "zope-dev" question... I removed it. Sean Kelley writes:
I am trying to test whether or not 3 SQL fields are equal to a form field. I am doing this within an SQL method. (I am trying to learn zope and Mysql at the sam time) How does one do this? Here is where I am going with this so far: I have these listed as arguments: Breeds Breed1 Breed2 Breed3
SELECT * from Ranch WHERE Breeds = <dtml-sqltest name="Breed1" type="string"> OR Breeds = <dtml-sqltest name="Breed2" type="string"> or Breeds = <dtml-sqltest name="Breed3" type="string"> Not sure whether MySQL supports this type of query, but usually you could use:
WHERE Breeds in (Breed1, Breed2, Breed3) BTW: "dtml-sqltest" is wrong above. As the name suggests, "sqltest" performs a test, but you use it as a variable above. For such cases, use "dtml-sqlvar". Dieter
Actual, the sqltest provides the multiple attribute for this case: WHERE <dtml-sqltest "[Breed1, Breed2, Breed3]" column="Breeds" type="int" multiple> Just my 0.02 Euro * Dieter Maurer <dieter@handshake.de> [020310 18:40]:
This was not a "zope-dev" question... I removed it. Actually that looked like a crosspost ...
Not sure whether MySQL supports this type of query, but usually you could use:
WHERE Breeds in (Breed1, Breed2, Breed3)
BTW: "dtml-sqltest" is wrong above. As the name suggests, "sqltest" performs a test, but you use it as a variable above. For such cases, use "dtml-sqlvar".
Dieter
Christian -- Christian Theune - ct@gocept.com gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981 reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])
participants (3)
-
Christian Theune -
Dieter Maurer -
Sean Kelley