Graham
|
| Posted: 04/23/2005, 2:46 PM |
|
Hi all, need some help with the SQL statement.
The aim is to do a search with a keyword "s_keyword1", find all the matches and make sure the field "active" contains a "1".
If active is a zero, the result is to be excluded. all this is then show in a grid.
My code so far is:
SELECT isbn, title, author, active
FROM books
WHERE ( isbn = '{s_keyword1}'
OR title = '{s_keyword1}'
OR author = '{s_keyword1}' )
AND active <> {1}
ORDER BY isbn
Unfortunately I can not get the part with "active" to work.
Any help for me please.
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 04/23/2005, 2:53 PM |
|
You don't need to put brackets around '1' and if you want to pull active records then use = instead of <>.
This should work:
AND active = 1
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Graham
|
| Posted: 04/23/2005, 3:19 PM |
|
I tried that, but get no returns at all.
Any other suggestions?
|
|
|
 |
dsafar
|
| Posted: 04/23/2005, 7:27 PM |
|
You need to use the like comparison operator instead of = as follows
SELECT isbn, title, author, active
FROM books
WHERE ( isbn like '%{s_keyword1}%'
OR title like '%{s_keyword1}%'
OR author like ''%{s_keyword1}%' )
AND active =1
ORDER BY isbn
"Graham" <Graham@forum.codecharge> wrote in message
news:6426ac22a7c85d@news.codecharge.com...
> Hi all, need some help with the SQL statement.
>
> The aim is to do a search with a keyword "s_keyword1", find all the
> matches and
> make sure the field "active" contains a "1".
>
> If active is a zero, the result is to be excluded. all this is then show
> in a
> grid.
>
> My code so far is:
>
> SELECT isbn, title, author, active
> FROM books
> WHERE ( isbn = '{s_keyword1}'
> OR title = '{s_keyword1}'
> OR author = '{s_keyword1}' )
> AND active <> {1}
> ORDER BY isbn
>
> Unfortunately I can not get the part with "active" to work.
>
> Any help for me please.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 04/23/2005, 10:47 PM |
|
If this doesn't work then "active = 1" is not a problem. Try this to see that active works:
SELECT isbn, title, author, active FROM books WHERE AND active =1 ORDER BY isbn
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
|