• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySQL Query help..

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a problem trying to figure out if I can build a query correctly. I have a table called system_table that looks something like:

I then have a table called tech_table which looks something like:

Now what I need to do is possibly build a single SELECT statement that will produce the following similar output

The problem I am having is figuring out how to get the realname based on the techid in a single query if that is possible.
Thanks for any tips.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35274
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exact syntax is database dependent, but here is the idea in roughly db2 syntax:
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne. After a few hours I finally figured out that MySQL 4.0 doesn't support subqueries so I had to upgrade to 4.1. Anyway, here is the current SQL:

This is getting close. Only now it is returning 55 rows. And currently there are only 13.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, turns out that is was because of my data. Since system had duplicates it was able to pull out more copies of the same record. The live data won't have duplicates so I think I will be ok.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic