using like and where in a joined query.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • leelotis
    New Member
    • Dec 2009
    • 14

    using like and where in a joined query.

    Hi im doing the following query

    Code:
    SELECT * FROM networkinfo JOIN tblimage WHERE networkinfo.network LIKE '$data' && networkinfo.network = tblimage.imgdata && networkinfo.category = '$category'
    so I can get it to work untill I add the last

    Code:
    && networkinfo.category = '$category'
    this kills the whole query what am I doing wrong? I think it has to do with using the like and where in the same query because I havnt run into this issue before the query seems simple enough to me.

    Thanks
  • ssnaik84
    New Member
    • Aug 2009
    • 149

    #2
    check for following conditions -
    1) if you are using "JOIN", you should use "ON" keyword to map tables
    2) if networkinfo.cat egory is integer, then remove single quote (')
    3) try using "AND" instead of "&&"

    Comment

    • ssnaik84
      New Member
      • Aug 2009
      • 149

      #3
      try printing your SQL stmt variable. and run directly on Query Browser

      Comment

      • mwasif
        Recognized Expert Contributor
        • Jul 2006
        • 802

        #4
        What do you mean by 'kills the whole query'?

        Don't mix JOIN with WHERE clause. Try the following

        [CODE=mysql]SELECT * FROM networkinfo
        INNER JOIN tblimage
        ON networkinfo.net work = tblimage.imgdat a
        WHERE networkinfo.net work LIKE '$data' AND networkinfo.cat egory = '$category'[/CODE]

        Comment

        • nbiswas
          New Member
          • May 2009
          • 149

          #5
          using like and where in a joined query

          Try this

          SELECT * FROM networkinfo
          JOIN tblimage
          ON networkinfo.net work = tblimage.imgdat a
          WHERE networkinfo.net work LIKE '%data'
          AND networkinfo.cat egory = 'category'

          Like should be '%data' as far as I know.
          and Join condition should be before the where condition

          Hope this helps

          Comment

          • leelotis
            New Member
            • Dec 2009
            • 14

            #6
            thanks

            great that fixed everything..... .... : )

            Comment

            Working...