close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

MySQL vs MSSQL - having real problems with INNER JOIN

Thread began 1/08/2014 9:07 am by Nathon Jones Web Design | Last modified 1/09/2014 11:47 am by Patrice | 3926 views | 8 replies |

Nathon Jones Web Design

MySQL vs MSSQL - having real problems with INNER JOIN

Jings, this is going to be tougher than I thought. I'm so used to MSSQL. :(

What is the issue with running an INNER JOIN select statement?
Here's what it used to look like in MSSQL:

SELECT dbo.LEDprods.LEDid, dbo.LEDprods.LEDdelete, dbo.LEDprods.LEDproductcode, dbo.LEDprods.LEDcatID, dbo.LEDprods.LEDfittingID,
dbo.LEDprods.LEDstyleID, dbo.LEDprods.LEDwattageID, dbo.LEDprods.LEDcolourID, dbo.LEDprods.LEDdimmable, dbo.LEDprods.LEDfrostedclear,
dbo.LEDprods.LEDlumensID, dbo.LEDprods.LEDsensor, dbo.LEDprods.LEDprice, dbo.LEDprods.LEDimg, dbo.LEDprods.LEDchipsID,
dbo.LEDwattage.LEDwattage, dbo.LEDstyle.LEDstyle, dbo.LEDlumens.LEDlumens, dbo.LEDfitting.LEDfitting, dbo.LEDcolour.LEDcolour,
dbo.LEDchips.LEDchips, dbo.LEDcats.LEDcat
FROM dbo.LEDprods INNER JOIN
dbo.LEDcats ON dbo.LEDprods.LEDcatID = dbo.LEDcats.LEDcatID INNER JOIN
dbo.LEDchips ON dbo.LEDprods.LEDchipsID = dbo.LEDchips.LEDchipsID INNER JOIN
dbo.LEDcolour ON dbo.LEDprods.LEDcolourID = dbo.LEDcolour.LEDcolourID INNER JOIN
dbo.LEDfitting ON dbo.LEDprods.LEDfittingID = dbo.LEDfitting.LEDfittingID INNER JOIN
dbo.LEDlumens ON dbo.LEDprods.LEDlumensID = dbo.LEDlumens.LEDlumensID INNER JOIN
dbo.LEDstyle ON dbo.LEDprods.LEDstyleID = dbo.LEDstyle.LEDstyleID INNER JOIN
dbo.LEDwattage ON dbo.LEDprods.LEDwattageID = dbo.LEDwattage.LEDwattageID
WHERE (dbo.LEDprods.LEDdelete = 0)

Here's what I changed it to for MySQL:

SELECT LEDprods.LEDid, LEDprods.LEDdelete, LEDprods.LEDproductcode, LEDprods.LEDcatID, LEDprods.LEDfittingID,
LEDprods.LEDstyleID, LEDprods.LEDwattageID, LEDprods.LEDcolourID, LEDprods.LEDdimmable, LEDprods.LEDfrostedclear,
LEDprods.LEDlumensID, LEDprods.LEDsensor, LEDprods.LEDprice, LEDprods.LEDimg, LEDprods.LEDchipsID,
LEDwattage.LEDwattage, LEDstyle.LEDstyle, LEDlumens.LEDlumens, LEDfitting.LEDfitting, LEDcolour.LEDcolour,
LEDchips.LEDchips, LEDcats.LEDcat
FROM LEDprods INNER JOIN
LEDcats ON LEDprods.LEDcatID = LEDcats.LEDcatID INNER JOIN
LEDchips ON LEDprods.LEDchipsID = LEDchips.LEDchipsID INNER JOIN
LEDcolour ON LEDprods.LEDcolourID = LEDcolour.LEDcolourID INNER JOIN
LEDfitting ON LEDprods.LEDfittingID = LEDfitting.LEDfittingID INNER JOIN
LEDlumens ON LEDprods.LEDlumensID = LEDlumens.LEDlumensID INNER JOIN
LEDstyle ON LEDprods.LEDstyleID = LEDstyle.LEDstyleID INNER JOIN
LEDwattage ON LEDprods.LEDwattageID = LEDwattage.LEDwattageID
WHERE (LEDprods.LEDdelete = 0)

Now, before you point out that you can't have a field name called the same as the table name, I've changed that but it just doesn't work. No errors are reported, it's just that no table rows are shown.

Is there something obvious that I've missed here. Please bear with my btw. I really want to port everything to PHP/MySQL and it's going to take me some time to adjust.

With that in mind, can anyone point me in the direction of a good website or forum for these types of headaches, ie. one that helps peopel make this transition from Classic ASP and MSSQL to PHP and MySQL?

Much appreciated.
NJ

Sign in to reply to this post

Jason ByrnesWebAssist

bear in mind that different join types return different results.

with an inner join, a result will only be returned if there is a match on both sides of the join predicate.

with the number of tables that you are joining, I'm going to bet that at least one of the join pairs is not making a match so is not returning a result.

to trouble shoot, change the select to:
SELECT *

then add one join at a time:
FROM LEDprods
INNER JOIN LEDcats ON LEDprods.LEDcatID = LEDcats.LEDcatID

test that then add the second:
FROM LEDprods
INNER JOIN LEDcats ON LEDprods.LEDcatID = LEDcats.LEDcatID
INNER JOIN LEDchips ON LEDprods.LEDchipsID = LEDchips.LEDchipsID


test again and so on.

once you stop getting a result revert to a simpler query with only the last join that you added.


your jumping in on the deep end with such a complex query. Get your feet wet with something simper first.


also look into a GUI SQL Tool such as Heidi SQL for building queries with a visual builder.

Sign in to reply to this post

Nathon Jones Web Design

good advice, as ever

Thank you Jason.

I've installed and configured HeidiSQL but, unlike SQL Server Management Studio, I can't easily see how I add tables to create a View, which is how I'm creating this INNER JOIN query. In SQLSMS I can simply select, from a list, all of the tables I want to use in my query (A view is just another name for a query table, right?). Where, in HeidiSQL, is the visual builder?

Thank you again for all your help Jason. My intention is to purchase eCart in the next month or two and really push on with developing in PHP.
I only hope that it, too, doesn't die like Classic ASP did.

Oh, and with that in mind, is there an upgrade option for eCart? I'm currently using version 4.5.2.

Much appreciated.
NJ

Sign in to reply to this post

Jason ByrnesWebAssist

there is a query builder on the query tab
http://www.heidisql.com/screenshots.php?which=query


or perhaps you want more of a automated builder like is available in Navicat:
http://www.navicat.com/manual/online_manual/en/navicat/linux_manual/QueryBuilder.html



the upgrade price for eCart will be $99, if you are interested, there will be a live demo of eCart 6 this saturday.

Sign in to reply to this post

Nathon Jones Web Design

GMT for eCart demo?

Hi Jason. Sorry what time, GMT, is the eCart demo?

Sign in to reply to this post

Jason ByrnesWebAssist

http://www.webassist.com/watch-and-learn/ecart-6-live-tour

it's at 9am - 11am PST, So that would be 5pm - 7pm GMT if my calculations are correct.

Sign in to reply to this post

PatriceWebAssist

Looks exciting!

Displays are all responsive now and optimize your shopping cart for smartphones and tablets, in addition to desktop displays.
Checkout wizard is now tab based, making set up of your checkout pages much more efficient (no longer a 12 step process!)

Will the tour be available later also?

If my math is right noon on EST time. Looking forward to it.

When will it be available to upgrade?

Sign in to reply to this post

Jason ByrnesWebAssist

Yes a recording of the tour will be made available.

Yes, 9am PST is 12PM EST

We hope to have the upgrade available right after the tour, but are still working out some issues, so no guarantees.

Sign in to reply to this post

PatriceWebAssist

Excellent. Very excited about the upgrade.
Happy to beta test on Mac; I will be upgrading for sure.

Sign in to reply to this post

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

Content

rating

Layout

rating

Ease of use

rating

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...