Re: Join tables

From: Date: Thu, 28 Feb 2002 17:26:47 +0000
Subject: Re: Join tables
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-17366@lists.php.net to get a copy of this message
Microsoft Access: light-duty relational database with a world-class (in my opinion) GUI interface, but I don't think it's going to help you in this case. > > > id in image_data has the same value as id in wt_users do you mean uid in wt_users? So, $id=session ID? I might set that ahead of time just to make it simpler. Therefore, you really only need one select statement. I'm no expert at this, and you may need to tweak this a little, but this should work : select <tablename>.<fieldname>, <tablename>.<fieldname> from wt_users, image_data where $id=wt_users.uid and $id=image_data.id substitute the table name and field names for <tablename>.<fieldname>, obviously. For example, wt_users.uid, image_data.id and so forth. That should get you on your way. aron "Jennifer Downey" <jendowney@attbi.com> wrote in message news:20020228101534.21719.qmail@pb1.pair.com... > Ok thanks for that info, but I guess I am ignorant to what MS Access is. > Please enlighten me. > > > Thanks > Jennifer Downey > > > "Marius Ursache" <marius.ursache@tm.cit.alcatel.fr> wrote in message > news:3C7DFB13.FFA8797B@tm.cit.alcatel.fr... > > the best tool for building "join" queries is MS Access . > > > > make a db same as that you use in mysql and build the query with access. > then copy/paste queries from there. > > > > to build queries in access is very simple . drag/drop and other visual > ways. > > > > > > Jennifer Downey a écrit : > > > > > Hi all, > > > > > > Ok first I have figured out my question on storing an image path. > > > > > > my question now is on joining data from two tables. > > > > > > wt_users has two fields (cols) called > > > uid and pid, > > > uid refers to the user > > > pid refers to the users pet > > > > > > image_data has a field called > > > id which refers to the image path > > > > > > id in image_data has the same value as id in wt_users > > > 1 1 > > > > > > These two queries are what are needed to get the image to display: > > > $pet = mysql_query("select id from wt_users where > uid={$session["uid"]}"); > > > $ret = mysql_query($pet); > > > > > > $query = "select binary_data,filetype from image_data where id=$id"; > > > $result = @mysql_query($query); > > > > > > I'm using echo "<img src=\"petdata.php?id= this should > > > correspond > with both id's \">"; to display the image > > > > > > how do I join the two tables so that the id's match and give the correct > image? > > > > > > And again thanks in advance for your help > > > Regards > > > Jennifer Downey > > > > > > P.S. I have looked at the mysql manual and a few tutorials. None of them > helped or worked. > > > > -- > > Marius Ursache (3563 || 3494) > > > > \|/ ____ \|/ > > "@'/ ,. \`@" > > /_| \__/ |_\ > > \__U_/ > > > > > >

« previous php.db (#17366) next »