PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
nishmgopal
Forum Contributor
Posts: 101 Joined: Tue Mar 03, 2009 9:38 am
Post
by nishmgopal » Sun Mar 22, 2009 2:32 pm
Hi, This is my code:
Code: Select all
$sql= "SELECT Job_ID.Job_name, ID_Table.Skill_Name, ID_Table.Weight
FROM Job_ID
JOIN ID_Table USING (Job_ID)
WHERE Job_ID.Job_Name = 'Manager'
";
$sql2="SELECT Person_ID.Person_Name, Person_Skill.Skill_Name, Person_Skill.Score
FROM Person_ID
JOIN Person_Skill USING (Person_ID)
WHERE Person_ID.Person_Name='Nish'";
$result1 = mysql_query($sql,$sql2)
or die ("Couldn't execute query.");
while ($row1=mysql_fetch_array($result1))
{
$tblRows .= "<tr>";
$tblRows .= "<td>{$row['Skill_Name']}</td>";
$tblRows .= "<td>{$row['Weight']}</td>";
$tblRows1 .= "<td>{$row1['Score']}</td>";
$tblRows1 .= "</tr>\n";
}
I get an invalid arguement error...is what I am trying to do even possible?
aditya2071990
Forum Contributor
Posts: 106 Joined: Thu May 22, 2008 11:30 am
Location: Hyderabad, India
Contact:
Post
by aditya2071990 » Sun Mar 22, 2009 2:36 pm
No, it is not valid. The arguments you can supply to mysql_query are the query string and the link identifier[the mysql connection to which you are referring to]. You'll have to do the "connecting" part inside the query itself...
http://in.php.net/manual/en/function.mysql-query.php
nishmgopal
Forum Contributor
Posts: 101 Joined: Tue Mar 03, 2009 9:38 am
Post
by nishmgopal » Sun Mar 22, 2009 2:39 pm
so even this wouldnt work?:
I tried it and got the error: Couldn't execute query.
Could you adivce me on how I can combine the two within the query?
aditya2071990
Forum Contributor
Posts: 106 Joined: Thu May 22, 2008 11:30 am
Location: Hyderabad, India
Contact:
Post
by aditya2071990 » Sun Mar 22, 2009 3:27 pm
What exactly are you trying to do with those queries?
Inkyskin
Forum Contributor
Posts: 282 Joined: Mon Nov 19, 2007 10:15 am
Location: UK
Post
by Inkyskin » Sun Mar 22, 2009 3:28 pm
Actually this is possible, but with mysqli (which to be honest is the best way to be doing things anyway), have a look here:
http://us2.php.net/manual/en/mysqli.multi-query.php
If your not comfortable with the Object Orientated style of mysqli, you can still use it in a procedural style too.