Author Topic: relationships in mysql  (Read 434 times)

0 Members and 1 Guest are viewing this topic.

Offline ohitsmeTopic starter

  • Irregular
  • Posts: 12
    • View Profile
relationships in mysql
« on: November 23, 2008, 08:21:11 PM »
hi,
i know when ive used ms access, i could set it up so i could do something like (i have forgotten the syntax of mssql so this is mysql language)

select table1.title,table2.amount from table1 where table1.id=123

(ie, set it up so it knows what the primary and foreign keys are, and not require any join statements or where table1.id = table2.prodid)

is there any way to set up things like this in mysql?

thanks

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,256
    • View Profile
Re: relationships in mysql
« Reply #1 on: November 23, 2008, 08:54:11 PM »
Take a look here.

Offline xtopolis

  • Devotee
  • Posts: 1,422
  • Gender: Male
  • [Can't stop. Won't stop.]
    • View Profile
Re: relationships in mysql
« Reply #2 on: November 23, 2008, 10:04:28 PM »
I think you can do:
Code: [Select]
SELECT table1.title, table2.amount from table1, table2 WHERE table1.id=123
but you'd probably need a WHERE modifier for table2 as well..

I don't know.. I don't do it that way.. is there a reason you're avoiding joins?