Results 1 to 13 of 13

Thread: Advanced SELECT. To hard for you!?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100
    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!

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196
    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'

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100
    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"

  5. #5
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196
    Assuming that you just cut and paste this from your code,

    is it because your column name WHERE Titel should be Title?

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100
    I must use WHERE in the query and where shall I put "WHERE" if not at the current possition???

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100
    "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%'

  9. #9
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196
    What exactly is your error message?

  10. #10

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100

    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 =(

  11. #11

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100
    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?

  12. #12
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196
    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).

  13. #13

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100
    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
  •  



Click Here to Expand Forum to Full Width