Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
fumpr
Starting Member
5 Posts |
Posted - 2010-02-16 : 11:41:35
|
Hi,I'm from Belguim and i'm making a diet program.Can anybody tell me what is wrong in this sql statement , is use the INNER JOIN keyword to connect the 2 tablestable1 = gebruikeretentable2= voedingnote : the "( )" is the english translation of the dutch wordThere are 4 fields in gebruikereten:Naam ( name of the food )Hoeveelheid ( amount)Eenheid ( Unit )Username ( Username )And 4 fields in voeding:Voeding ( name of the food )Eiwit ( amount of Protein )VET ( amount of FAT )Koolh ( amount of carbohydrates )Now I want to see what user ' fumpr ' has eaten and how much pro, cabs and fat that kind of food contain, So I do this :SELECT gebruikereten.NAAM, voeding.EIWIT, voeding.VET, voeding.Koolh, gebruikereten.HOEVEELHEIDFROM gebruikereten WHERE Username= 'fumpr'INNER JOIN voedingON gebruikereten.NAAM= voeding.VOEDING But I get the error:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN voeding ON gebruikereten.NAAM= voeding.VOEDING LIMIT 0, 30' at line 3Can anybody help me please?Thank you |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-02-16 : 11:43:58
|
It should beSELECT gebruikereten.NAAM, voeding.EIWIT, voeding.VET, voeding.Koolh, gebruikereten.HOEVEELHEIDFROM gebruikereten INNER JOIN voedingON gebruikereten.NAAM= voeding.VOEDINGWHERE gebruikereten.Username= 'fumpr' |
 |
|
|
fumpr
Starting Member
5 Posts |
Posted - 2010-02-16 : 11:49:03
|
| Yes it works :) thank you !!!! |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-02-16 : 12:26:28
|
| Ok..Gr8. |
 |
|
|
fumpr
Starting Member
5 Posts |
Posted - 2010-02-16 : 13:15:14
|
| oke i'm at the next problem right now :)this is not a sql problem but php how do I print the tabel ?i do this$result2 = mysql_query("SELECT gebruikereten.NAAM, voeding.EIWIT, voeding.VET, voeding.Koolh, gebruikereten.HOEVEELHEIDFROM gebruikeretenINNER JOIN voeding ON gebruikereten.NAAM = voeding.VOEDINGWHERE gebruikereten.Username = '$uname'"); while($row = mysql_fetch_array($result2)){ $EIW = $row['EIWIT']; $VET = $row['VET']; $KH = $row['Koolh']; $Hoeveelheid = $row['HOEVEELHEID'] / 100; echo " $EIW "; echo " $VET "; echo " $KH "; echo " $Hoeveelheid "; } |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2010-02-16 : 13:30:33
|
| you might be better of seeking help at the PHP forum for that one...___________________________________________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.7 out! |
 |
|
|
|
|
|
|
|