Click to See Complete Forum and Search --> : [RESOLVED] Don't know how to word this...
I have searched, but I don't know exactly WHAT to search for because im an idiot. This is probably really easy, I am new to SQL and have a decent understanding of it...just get stumped sometimes. Here is what I need to do:
Lets say I have 2 tables. One of them having abbreviated locations (i.e. DFW, SAN, etc.).
The second table having this information, AS WELL AS, the full name (i.e. DALLAS, SAN FRANSISCO,etc.)
What I want to be able to do is take the info from the 1st table and have it look it up in the 2nd table and display it as the "FULL NAME".
Does that make sense?
Thanks.
I figured this out but now I am stuck again. I want to do this for 2 different cities in the same query. Is that even possible?
tgormtx
10-08-2007, 03:08 PM
Can you give me the table structure of each table?
Hey,
Okay I have 2 tables. Simplified here..
1st table, im only actually using 2 columns out of the table. (startloc and stoploc)
2nd table, also only using 2 of the columns (citycode and longname) and citycode is the same as the startloc and stoploc values. longname has the actual city name (i.e. dallas) The startloc, stoploc, citycode all have values like (DFW, SAN, etc.)
I want to be able to display like this "startloc - stoploc" but in the LONGNAME value. I figured out how to get one..but then found that I couldnt do 2 different ones. does that make sense?
flightSelect = new java.lang.StringBuffer("SELECT W.LONGNAME AS FLIGHT,D.CATEGORY AS FTYPE,D.STARTLOC,D.STOPLOC,D.STARTTIME");
flightSelect.append(" AS DEPART,D.STOPTIME AS ARRIVE,D.STARTDATE,D.STOPDATE,D.QTY AS TICKETS");
flightSelect.append(" FROM WSCITY W, WSORD_DET D WHERE W.CITYCODE=D.STARTLOC AND D.ITEMTYPE=\"AIR\" AND D.OHLINK=");
flightSelect.append(ohlink);
tgormtx
10-08-2007, 03:20 PM
It does makes sense if I am understanding it correctly. You would need to use 2 queries to display what you want. I was thinking you wanted to display multiple columns from each table is a single table, but you do need 2.
One for the start, one for the stop.
yeah, I just edited my previous post with my code/select statement that works fine. I just need to know how to change both (without having to created a new stringbuffer/vector). Is it even possible? I tried a little bit using UNION SELECT but couldnt get it to work because I was trying to 1 column as 2 columns...which doesn't work haha..hard to explain.
SOLUTION:
TAKE THE LONG WAY, CREATE NEW QUERY AND COMBINE THEM. Who would have though??? I guess im lazy.