|
-
Sep 18th, 2000, 01:11 PM
#1
Thread Starter
Lively Member
Hi.
I got a database like this
Title | Language
Test1 en
Test2 en
Test3 se
and I want so search on the Title and with a language. Sometimes "en" and "se" and sometime just one language. I created this query but I can't make it work with the "language" selection. Any idéa how to combine several boolean expressions??
Code:
SQL = "SELECT * From Stories"
SQL = SQL & " WHERE Titel LIKE '%" & Request.Form("titel") & "%'"
If Request.Form("swedish") <> "ON" Then SQL = SQL & " AND Language = 'se'"
If Request.Form("english") <> "ON" Then SQL = SQL & " AND Language = 'en'"
Tnx!
-
Sep 18th, 2000, 01:14 PM
#2
Monday Morning Lunatic
Try using:
Code:
AND (Language = 'se' OR Language = 'en')
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 18th, 2000, 01:17 PM
#3
Addicted Member
Language can only have one value right? Then using "AND" would make it wrong... it should either be just
Swedish ... = 'se'
English ... = 'en'
Both ... 'se' OR 'en'
-
Sep 18th, 2000, 01:42 PM
#4
Thread Starter
Lively Member
Multiple language is OK.
I got error then I run this query:
SELECT * From Stories WHERE Titel LIKE '%all%' AND (Language = 'se' OR Language = 'en')
I think this looks okey but I got an unspecified error when I "rs.Open SQL, Conn"
I can run more simple questions like "SELECT * From Stories ORDER BY ID DESC"
-
Sep 18th, 2000, 01:53 PM
#5
Addicted Member
Assuming that you just cut and paste this from your code,
is it because your column name WHERE Titel should be Title?
-
Sep 18th, 2000, 01:56 PM
#6
Thread Starter
Lively Member
I must use WHERE in the query and where shall I put "WHERE" if not at the current possition???
-
Sep 18th, 2000, 02:03 PM
#7
Monday Morning Lunatic
He means replace Titel with Title.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 18th, 2000, 02:10 PM
#8
Thread Starter
Lively Member
"titel" is right.
Titel is the swedish word for title and when I created the database I used all english words except the "titel". But that is not the problem because I can run questions like:
SELECT * From Stories WHERE Titel LIKE '%yellow%'
-
Sep 18th, 2000, 02:20 PM
#9
Addicted Member
What exactly is your error message?
-
Sep 18th, 2000, 02:28 PM
#10
Thread Starter
Lively Member
search result: SELECT * From Stories WHERE Titel LIKE '%%%' AND (Language = 'en') fel '80004005'
Odefinierat fel
/stories.asp, line 389
I past the exact output from my ASP page. I print the variable SQL for debug and it's the "SELECT......" part.
The text "fel '80004005' Odefinierat fel" is "ERROR '80004005' underfined error" in english and that part is the server that says
/stories.asp, line 389 : That is the part where I execute the query:
rs.Open SQL, Conn
This is not fun anymore =(
-
Sep 18th, 2000, 02:54 PM
#11
Thread Starter
Lively Member
cool.. reserved words..
yeah. it works with [Language].. TNX!!!
eh.. works is a strong word. I don't get any errormessage now but I dont any hits.. strange.
Does SQL think that [Language] is a "string" now instead of a column?
-
Sep 18th, 2000, 03:00 PM
#12
Addicted Member
exactly what is the datatype definition of your columns in your table? when you put things in a brace, it treats it as an onject. [TABLE], [COLUMN] etc. its not a string. Check your language column declaration... it should be char(2).
-
Sep 18th, 2000, 03:13 PM
#13
Thread Starter
Lively Member
duh..
I changed the name instead. Now is it called "Lang".
Thanks 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
|
Click Here to Expand Forum to Full Width
|