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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 LIMIT HELP

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 tables
table1 = gebruikereten
table2= voeding

note : the "( )" is the english translation of the dutch word

There 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.HOEVEELHEID
FROM gebruikereten WHERE Username= 'fumpr'
INNER JOIN voeding
ON 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 3

Can anybody help me please?

Thank you

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-02-16 : 11:43:58
It should be
SELECT gebruikereten.NAAM, voeding.EIWIT, voeding.VET, voeding.Koolh, gebruikereten.HOEVEELHEID
FROM gebruikereten INNER JOIN voeding
ON gebruikereten.NAAM= voeding.VOEDING
WHERE gebruikereten.Username= 'fumpr'



Go to Top of Page

fumpr
Starting Member

5 Posts

Posted - 2010-02-16 : 11:49:03
Yes it works :)
thank you !!!!
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-02-16 : 12:26:28
Ok..Gr8.
Go to Top of Page

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.HOEVEELHEID
FROM gebruikereten
INNER JOIN voeding ON gebruikereten.NAAM = voeding.VOEDING
WHERE 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 ";

}
Go to Top of Page

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 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.7 out!
Go to Top of Page
   

- Advertisement -