-1

I have a sqlite database avalible here => https://www.dropbox.com/s/9cn093ns3ot2cik/drinks.db?dl=0

I'm trying to show ( or replace?) the drinks.glass_id with its proper name from glasses.name

I have tried

select drinks._id DID, 
       drinks.glass_id GID,
       glasses.name GNAME,
       glasses._id GIDD 
from drinks DRNKS
     join glasses GLS
     on drinks.glass_id = glasses._id

What is wrong??
I have spent several hours looking this up. I have read these links and still cant figure it out.

http://community.spiceworks.com/topic/242166-sql-query-help-convert-category-id-to-the-text-name

Replacing a pulled SQL ID value with its name from another table

How to replace fetched values with another column while querying with SQL Server 2008 R2

how to get name from another table with matching id in another table?

Community
  • 1
  • 1
Tony
  • 121
  • 2
  • 13

1 Answers1

1

If you specify an alias for your tables then you have to use it everywhere

select d._id DID, 
       d.glass_id GID,
       g.name GNAME,
       g._id GIDD 
from drinks d
join glasses g on d.glass_id = g._id
juergen d
  • 201,996
  • 37
  • 293
  • 362