Hi I am fairly new to SQL - so be gentle with me!
I basically have two tables that I am trying to join where the primary key in the first table is used multiple times in the second table (and forms the primary key in the second table along with another column)
It's probably best if I provide an example:
Table 1 : TravelRecords
TravelEventID EventType RecordLocator OfficeID
0001 F ABC123 LDN
0002 F ABC234 LDN
0003 T BDF232 SOU
0004 F DFD890 GLA
Table 2 : TravelRecordRmks
TravelEventID RemarkNo Keyword Text
0001 1 TVL LOWCOST BOOKING
0001 2 TVL CREDIT CARD USED
0001 3 PSG COST CENTRE REQUIRED
0001 4 PSG EMPLOYEE NUM REQUIRED
0002 1 TVL CREDIT CARD USED
0002 2 AGT BOOKED BY AGENT
0002 3 AGT CONFIRM WITH AIRLINE
0002 4 TVL LOWEST FARE CONFIRMED
0002 5 TVL NO CANCELLATION CHARGE
0003 1 TVL LOWCOST BOOKING
0003 2 TVL CARRIER : EASYJET
0003 3 TVL LOWEST FARE CONFIRMED
0004 1 TVL LOWCOST BOOKING
0004 2 TVL CREDIT CARD USED
For the second table the key is the combination of the TravelEventID and the RemarkNo which combined gives a unique ID.
Basically all I am trying to do is join the tables together and return the record locator for bookings that have a remark text line of LOWCOST BOOKING AND CREDIT CARD USED (so in the example above only ABC123 and DFD890 should be returned.
I've tried something along the lines of :
SELECT TravelRecords.RecordLocator
FROM TravelRecords INNER JOIN
TravelRecordRmks ON TravelRecords.TravelEventID = TravelRecordRmks.TravelEventID db
WHERE (TravelRecordRmks.RemarkText = 'LOWCOST BOOKING')
and (TravelRecordRmks.RemarkText = 'CREDIT CARD USED')
ORDER BY dbo.vw_gTravelOrderEvent.RecordLocator
However - that returns nothing. This is probably really simple - but I can't get it to return the required response when I am looking for the single TravelEventID to contain both Remark Text fields.
Any help much appreciated Cheers