query problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Diz
    New Member
    • Feb 2006
    • 19

    query problem

    Can anyone please help with this?
    when i run the following query, using SELECT*,

    SELECT *
    FROM tbl_artwork, tbl_artworkmedi um, tbl_medium
    WHERE tbl_artwork.art workID = tbl_artworkmedi um.artworkID
    AND tbl_artworkmedi um.mediumID = tbl_medium.medi umID
    AND `dateCreated` =2002

    I get more info than i need, (lots of IDs displaying) and type displays oil or watercolour etc. but when i try to get rid of the extra info by running a query which individually specifies the fields, the 'type' shows up as 'type' instead of content of type field. Hope I'm explaining this ok....


    SQL-query:
    SELECT `title` , `category` , `cost` , `image` , `size` , `paintedOn` , 'type', `dateCreated`
    FROM tbl_artwork, tbl_artworkmedi um, tbl_medium
    WHERE tbl_artwork.art workID = tbl_artworkmedi um.artworkID
    AND tbl_artworkmedi um.mediumID = tbl_medium.medi umID
    AND `forSale` = 'Yes'

    this is the result:

    title category cost image size paintedOn type dateCreated
    Abstract Blue 1 Abstract 250 2000*2500mm canvas type 2001
    Abstract Blue 2 Abstract 250 2500*2000mm canvas type 2001
    Abstract multi 2 Abstract 290 3000*3000mm canvas type 2002
    Abstract Multi 3 Abstract 280 3000*3000mm canvas type 2001
    Abstract Multi 6 Abstract 310 3000*2800mm canvas type 2001
    Abstract Multi 7 Abstract 290 3000*3000mm canvas type 2002

    ( i know the above query is to pull through different info than the first, but it's just to illustrate my problem) type is the only field in tblMedium other than the PK.
    thanks,
    Diz
  • CaptainD
    New Member
    • Mar 2006
    • 135

    #2
    Not sure what SQL language you're using, I use T-Sql (Microsoft) Anyway, looking at your SQL statement.
    SQL-query:
    SELECT `title` , `category` , `cost` , `image` , `size` , `paintedOn` , 'type', `dateCreated`
    FROM tbl_artwork, tbl_artworkmedi um, tbl_medium
    WHERE tbl_artwork.art workID = tbl_artworkmedi um.artworkID
    AND tbl_artworkmedi um.mediumID = tbl_medium.medi umID
    AND `forSale` = 'Yes'
    The characters that indicate a field look different then the quotes around 'type',
    I'm not sure what character you're using but the others kick back. Could that be your problem?

    Comment

    • Diz
      New Member
      • Feb 2006
      • 19

      #3
      that could be it, i'm using mysql in phpmyadmin, and i've added all of the other fields automatically, but had to type in 'type' myself. I'll have a good look at the keyboard and see if i can find a match for the other character. Thanks.

      Comment

      Working...