close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


Thread began 6/13/2011 9:41 pm by madelectrical386948 | Last modified 6/30/2011 5:48 pm by madelectrical386948 | 4430 views | 33 replies

Jenny I

Hi Mike

I was suggesting the AS operater is used when you need to join a table more than once in a mysql query. It is used so when you create your recordset you can have different recordset bindings for each of your options. So e.g. options1 is fake but it helps to distinguish your other options fields.

To help trouble shoot I created a mock database of your tables to see if I could get the query to work. My table was based on the first sample I gave you.

Company Index Table

companyIndexID (primary key) INT
companyID INT
optionsID INT
2. You should then have the company table which should look something like this

Company Table

companyID (primary key) INT
companyName VARCHAR
companyShortName VARCHAR
CompanyAddressNo VARCHAR
companyAddressLine1 VARCHAR
companyAddressline2 VARCHAR
companyCity VARCHAR
companyState VARCHAR
companyZipCode VARCHAR
3. Next your options table can be set up like this

options Table

optionsID (primary key)
optionName VARCHAR

Your data should look something like this

1. Facebook
2. Twitter
3. Webpage

If you wanted your company index table to have more that one option selected you could add

Company Index Table

companyIndexID (primary key) INT
companyID INT
options1ID INT
options2ID INT
options3ID INT
options4ID INT

I was able to get this to work using the following query

  SELECT companyindex.companyindexID, companyindex.companyID, companyindex.options1ID, companyindex.options2ID, companyindex.options3ID, companyindex.option4ID, company.companyname, options1.optionName, options2.optionName, options3.optionName, options4.optionName
FROM companyindex
INNER JOIN options AS options1 ON companyindex.options1ID = options1.optionsID
INNER JOIN options AS options2 ON companyindex.options2ID = options2.optionsID
INNER JOIN options AS options3 ON companyindex.options3ID = options3.optionsID
INNER JOIN options AS options4 ON companyindex.option4ID = options4.optionsID
INNER JOIN company ON companyindex.companyID = company.companyID  

I have attached an image just to show the result I came up with. Once this is working you will need to bind the recordsets fields to your page to display the data. When you bind to the page it would look something like this

  <?php echo $row_WADAcompanyindex['optionName']; ?>  

Each time you bind to the page you will need to prepend the options created using AS so

  To display option 1 (e.g facebook)
<?php echo $row_WADAcompanyindex['options1.optionName']; ?>

To display option 2 (e.g twitter)
<?php echo $row_WADAcompanyindex['options2.optionName']; ?>

To display option 3 (e.g Youtube)
<?php echo $row_WADAcompanyindex['options3.optionName']; ?>

To display option 4 (e.g Web)
<?php echo $row_WADAcompanyindex['options4.optionName']; ?>  

Just a little note I have used INNER JOIN but you should use LEFT JOIN, the results are exactly the same but INNER JOIN can cause problems at times.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...