Jump to content

Recordsets/Joining tables


Recommended Posts

hello all

im making a back office recruitment system using dreamweaver, and whilst its not going too badly, ive just hit a brick wall.

 

basically, i have two tables, Business Contacts (buscontacts) and Candidates (candidates). Both have fields fTitle (ie Mr, Mrs, Miss, etc), fForenames, fSurname.

 

ive written a query like:

SELECT buscontacts.fTitle,buscontacts.fForenames,buscontacts.fSurname, candidates.fTitle, candidates.fForenames, candidates.fSurname FROM mydatabase WHERE criteria matched

 

which basically selects the name of the interviewer/business contact and the name of the candidate they interviewed.

 

now - when i run this query using mysql from command line, it works and shows me what i want.

but in php/dreamweaver, the recordset ignores the duplicate fields. i tried to use:

$myrecordset['buscontacts.fForenames'] to distinguish it from $myrecordset['candidates.fForenames'] but that didnt work. how can i treat all the fields and display each data field as individual?

 

this is really doing my head in and ive searched around but not yet found an answer ... can anyone here help???

 

cheers

 

mark

 

Link to comment
Share on other sites

Try using the "as" when you have duplicate names:

 

SELECT buscontacts.fTitle as bus_title,buscontacts.fForenames as bus_forenames,buscontacts.fSurname as bus_surname, candidates.fTitle, candidates.fForenames, candidates.fSurname FROM mydatabase WHERE criteria matched

 

Link to comment
Share on other sites

Try using the "as" when you have duplicate names:

 

SELECT buscontacts.fTitle as bus_title,buscontacts.fForenames as bus_forenames,buscontacts.fSurname as bus_surname, candidates.fTitle, candidates.fForenames, candidates.fSurname FROM mydatabase WHERE criteria matched

216848[/snapback]

 

cheers bilbot, i managed to get this problem sorted on another thread, so for anyone else having the same problem : - SOLUTION

Link to comment
Share on other sites

  • 2 months later...
SELECT buscontacts.fTitle,buscontacts.fForenames,buscontacts.fSurname, candidates.fTitle, candidates.fForenames, candidates.fSurname FROM mydatabase WHERE criteria matched

 

Alias the field names

 

SELECT buscontacts.fTitle ftitlefrombus ,buscontacts.fForenames fForenamesfrombus ,buscontacts.fSurname fSurnamefrombus , candidates.fTitle fTitlefromcan

 

and so on and so forth

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.