SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: verify my query statement

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    verify my query statement

    What's wrong with this?

    Code:
    SELECT * FROM biblewheel_url INNER JOIN bible ON biblewheel_url.letter_id = bible.book_spoke WHERE ( text_data like '%number%' OR text_data like '%day%' OR text_data like '%forty%' OR text_data like '%year%' ) AND bible.book_spoke = '4' 
    Microsoft OLE DB Provider for ODBC Drivers error '80040e07' 
    
    [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. 
    
    /wheelofgod/kjvresp.asp, line 34
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    SQL Consultant silver trophybronze trophy
    SitePoint Award Recipient r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    38,463
    Mentioned
    35 Post(s)
    Tagged
    1 Thread(s)
    bible.book_spoke is probably a numeric column

    by the way, access uses * for the LIKE wildcard character, not %

    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you put a wrong delimiter on one of your table field

    For more info regarding your erro check out the link might help...
    http://www.adopenstatic.com/faq/80040e07.asp

    In addition basing on your sql statement below

    SELECT * FROM biblewheel_url INNER JOIN bible ON biblewheel_url.letter_id = bible.book_spoke WHERE ( text_data like '%number%' OR text_data like '%day%' OR text_data like '%forty%' OR text_data like '%year%' ) AND bible.book_spoke = '4'


    if bible.book_spoke is a text data type then the sql statement is correct but if it is a number data type then it should be like this...

    SELECT * FROM biblewheel_url INNER JOIN bible ON biblewheel_url.letter_id = bible.book_spoke WHERE ( text_data like '%number%' OR text_data like '%day%' OR text_data like '%forty%' OR text_data like '%year%' ) AND bible.book_spoke = 4

    HTH...
    Happy programming

  4. #4
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gladxml
    I think you put a wrong delimiter on one of your table field

    For more info regarding your erro check out the link might help...
    http://www.adopenstatic.com/faq/80040e07.asp

    In addition basing on your sql statement below

    SELECT * FROM biblewheel_url INNER JOIN bible ON biblewheel_url.letter_id = bible.book_spoke WHERE ( text_data like '%number%' OR text_data like '%day%' OR text_data like '%forty%' OR text_data like '%year%' ) AND bible.book_spoke = '4'


    if bible.book_spoke is a text data type then the sql statement is correct but if it is a number data type then it should be like this...

    SELECT * FROM biblewheel_url INNER JOIN bible ON biblewheel_url.letter_id = bible.book_spoke WHERE ( text_data like '%number%' OR text_data like '%day%' OR text_data like '%forty%' OR text_data like '%year%' ) AND bible.book_spoke = 4

    HTH...
    Happy programming
    SELECT * FROM biblewheel_url INNER JOIN bible ON biblewheel_url.letter_id = bible.book_spoke WHERE ( text_data like '%number%' OR text_data like '%day%' OR text_data like '%forty%' OR text_data like '%year%' ) AND bible.book_spoke = 4
    Thanks. That worked.
    Compare bible texts (and other tools):
    TheWheelofGod

  5. #5
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Assuming that number, day, and year are all variables rather than string literals, try the following

    =========================

    cn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;"

    set rs = server.createobject("adodb.recordset")

    sql = "SELECT biblewheel_url.*"
    sql = sql & " FROM biblewheel_url"
    sql = sql & " INNER JOIN bible ON biblewheel_url.letter_id = bible.book_spoke"
    sql = sql & " WHERE ("
    sql = sql & " biblewheel_url.text_data like '*" & number & "*'"
    sql = sql & " OR biblewheel_url.text_data like '*" & day & "*'"
    sql = sql & " OR biblewheel_url.text_data like '*forty*'"
    sql = sql & " OR biblewheel_url.text_data like '*" & year & "*'"
    sql = sql & ")"
    sql = sql & " AND bible.book_spoke = '4'"

    rs.open sql, cn
    if not rs.eof then
    do while not rs.eof
    response.write rs("biblewheel_url.text_data")
    rs.movenext
    loop
    end if
    rs.close
    set rs = nothing

    =========================

    Remember that an asterisk (*) is the wildcard for Access and percent (%) for SQL Server.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •