![](https://seccdn.libravatar.org/avatar/eedd9fb4827a9e56684e129940ceb863.jpg?s=120&d=mm&r=g)
I am not very good at SQL I'm just a lowly java programmer. So I have no ideas why this SQl statement is wrong: elect * from mytable where field1 like %word% or field2 like %word% and where field3 = number if I leave the "and where field3 = 2 " out the query works. The column is an int so that should work and indeed if I use "select * from mytable where field3 = 2" that works.... What is wrong with this (or me) ? Thanx Chris I'm lazy.. I'd rather smile and be happy, than work my face muscles so hard to frown... why not join me!!! -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
![](https://seccdn.libravatar.org/avatar/3c08eb5bb345f55e353570ed99a6e03e.jpg?s=120&d=mm&r=g)
Um you need quotes around the %word% and probably some parenthesis and kill
the last where
ie
elect * from mytable where (field1 like '%word%' or field2 like '%word%')
and field3=number
kw
/* Keith Warno
** Developer & Sys Admin
** http://www.HaggleWare.com/
*/
----- Original Message -----
From: "Brevsville Administrator"
![](https://seccdn.libravatar.org/avatar/1335d66c0c86070ceeb99f49682cf7b3.jpg?s=120&d=mm&r=g)
You probably need to put some parenthesis around your and/or criteria, ie: (field1 like %word% or field2 like %word%) and field3 = number OR field1 like %word% or (field2 like %word% and field3 = number) Chris Geske -----Original Message----- From: Brevsville Administrator [mailto:admin@brevsville.com.au] Sent: Friday, June 09, 2000 11:22 AM To: suse-linux-e@suse.com Subject: [SLE] SQL syntax I am not very good at SQL I'm just a lowly java programmer. So I have no ideas why this SQl statement is wrong: elect * from mytable where field1 like %word% or field2 like %word% and where field3 = number if I leave the "and where field3 = 2 " out the query works. The column is an int so that should work and indeed if I use "select * from mytable where field3 = 2" that works.... What is wrong with this (or me) ? Thanx Chris I'm lazy.. I'd rather smile and be happy, than work my face muscles so hard to frown... why not join me!!! -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/ -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
![](https://seccdn.libravatar.org/avatar/39ff405b4a31025d67ad73003f549250.jpg?s=120&d=mm&r=g)
Assuming this is mostly compatible SQL; the problem with your query is that it has two where clauses. You can have one where clause and multiple filters defined using the 'and' keyword. This is what your SQL should read: select * from mytable where (field1 like %word% or field2 like %word%) and (field3 = number) Play with the parenthesis rather then place another 'where' keyword in the same SQL statement. regards, Adi Gadwale. On Sat, 10 Jun 2000, Brevsville Administrator wrote:
I am not very good at SQL I'm just a lowly java programmer. So I have no ideas why this SQl statement is wrong:
select * from mytable where field1 like %word% or field2 like %word% and where field3 = number
if I leave the "and where field3 = 2 " out the query works.
The column is an int so that should work and indeed if I use "select * from mytable where field3 = 2" that works....
What is wrong with this (or me) ?
Thanx
Chris I'm lazy.. I'd rather smile and be happy, than work my face muscles so hard to frown... why not join me!!!
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
![](https://seccdn.libravatar.org/avatar/ed12bc54bc5b499307092e4c89135812.jpg?s=120&d=mm&r=g)
Hello Brevsville, on Saturday, June 10, 2000 at 02:12:02 +0000, you sat in front of your keyboard and wrote:
I am not very good at SQL I'm just a lowly java programmer. So I have no ideas why this SQl statement is wrong:
select * from mytable where field1 like %word% or field2 like %word% and where field3 = number
if I leave the "and where field3 = 2 " out the query works.
The column is an int so that should work and indeed if I use "select * from mytable where field3 = 2" that works....
What is wrong with this (or me) ?
Thanx
I'm not an SQL expert too but I think that should be typed like:
elect * from mytable where field1 like '%word%' or field2 like '%word%' and
field3 = number;
Hope this helps...
--
Jean-François Bocquet
![](https://seccdn.libravatar.org/avatar/d7f6399eb7cce1c563172ebdffe10692.jpg?s=120&d=mm&r=g)
Not sure if this is it or not, as I'm just learning SQL myself, but aren't you supposed to leave out the second occurence of the word "where"? - Mike On Sat, 10 Jun 2000, Brevsville Administrator wrote:
I am not very good at SQL I'm just a lowly java programmer. So I have no ideas why this SQl statement is wrong:
select * from mytable where field1 like %word% or field2 like %word% and where field3 = number
if I leave the "and where field3 = 2 " out the query works.
The column is an int so that should work and indeed if I use "select * from mytable where field3 = 2" that works....
What is wrong with this (or me) ?
Thanx
Chris I'm lazy.. I'd rather smile and be happy, than work my face muscles so hard to frown... why not join me!!!
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
participants (6)
-
adi@gadwale.com
-
admin@brevsville.com.au
-
keith@HaggleWare.com
-
lims@newnorth.net
-
mike@universe.ne.mediaone.net
-
tns01@free.fr