Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2007, 08:59 PM
Registered User
 
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP/MySQL Subquery Problem

I am trying to complete a subquery where I gather all the records for users who like a certain team. I have searched for a couple of hours online and can't find anything except subquery problems for users that are using an older version of MySQL -- I am using version 5.0.

Please help... the code is below:

$query = "SELECT userid,team FROM favteams WHERE userid = (SELECT userid FROM favteams WHERE team='uga')";
$result = mysql_query($query);

while ($row = mysql_fetch_array($result)){
    echo $row["userid"]."<br>";
}
 
Old April 18th, 2007, 11:31 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hi,
from your query i can understand, you are trying to get only userid.
simply SELECT userid FROM favteams WHERE team='uga'
you will get the userid, and team will be uga,
what you are trying to do?

surendran
(Anything is Possible)
http://ssuren.spaces.msn.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Query Problem w/ PHP rdmapes PHP How-To 5 August 14th, 2010 12:55 AM
mysql & php connection problem. Manu Sharma PHP Databases 2 March 2nd, 2007 07:03 AM
help with mysql subquery pnj MySQL 1 October 24th, 2006 05:42 PM
problem in mysql php charset yoord BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 April 11th, 2005 03:40 AM
problem with PHP - MYSQL in LINUX cnilashis PHP How-To 3 August 18th, 2003 02:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.