corillo181 Posted May 22, 2006 Share Posted May 22, 2006 [code]SELECT photo.*, # Field list albums.*FROM tra_photo photo, tra_albums albumsWHERE photo.album_id = album.album_id[/code]i always only pulled 2 table results from 2 tables.. but what if i wanted more then 2 coloums result how would i got about it? photo.photoname , albums(name,descibtion)??????? Quote Link to comment https://forums.phpfreaks.com/topic/10162-tables-select/ Share on other sites More sharing options...
chawezul Posted May 22, 2006 Share Posted May 22, 2006 It's kind of hard to understand what you're asking, plus you didn't show us how this query is applied to your code so it's harder to understand what you're trying to do with the result. But if you want to grab more columns (and assuming you don't have a million) you can simply use[code]SELECT * FROM `table` WHERE condition[/code]And that will grab all of the columns. Sorry if I didn't answer your question. Quote Link to comment https://forums.phpfreaks.com/topic/10162-tables-select/#findComment-37881 Share on other sites More sharing options...
corillo181 Posted May 22, 2006 Author Share Posted May 22, 2006 sorry.. what i'm trying to do is selecting from 2 tables.. more than 2 fields with out using * ..kind of like this$query=mysql_query("SELECT tra_photo.photoname, tra_albums.name FROM tra_photo, tra_albums WHERE tra_photo.album_id=tra_albums.album_id");but more than 2 fields Quote Link to comment https://forums.phpfreaks.com/topic/10162-tables-select/#findComment-37882 Share on other sites More sharing options...
Ferenc Posted May 22, 2006 Share Posted May 22, 2006 "SELECT row1_table1, row3_table2, row6table_1 FROM table_1, table_2" Quote Link to comment https://forums.phpfreaks.com/topic/10162-tables-select/#findComment-37884 Share on other sites More sharing options...
corillo181 Posted May 22, 2006 Author Share Posted May 22, 2006 yeah i'm kind growing in this.. now this my new and almost last question :Di still got one more after this one..i'm taking it step by step becuase i want to give a few try and make sure i know what i'm doing before i ask something else.. if i ask everything at once ppl are going to post a whole script and that wouldn't be learning..now this is many new question..ok i got the albums and the describtion and the name of the picture the belong to the album to display..the problem: every time a new picture is added it display all the information.. the album name and the album describtion..what i want to do: just add the name of the ne wpicture to dis play in the album it belongs to..this is how it looks:album name: clubspartyablum desc: pictures about clubs and partyphoto names: 920608809.jpgif add a ne wpicture just adds another rowalbum name: clubspartyablum desc: pictures about clubs and partyphoto names: new picture.jpghow i want it to look.. album name: dablockablum desc: Rep your block or whatever you want this is for the hoodphoto names: 27490662.jpg, new picture name,newpicture name, new picture name..this code doesn't do that.. help me fix that thanx..[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?phpsession_start();include_once'includes/db.php';$query=mysql_query("SELECT tra_albums.name,tra_albums.descrive,tra_photo.fotoname FROM tra_albums,tra_photo WHERE tra_albums.album_id=tra_photo.album_id LIMIT 3");while($array=mysql_fetch_array($query)){$name=$array['name'];$piname=$array['descrive'];$pname=$array['fotoname'];echo "album name: ".$name."<BR>"."ablum desc: ".$piname."<BR>"."photo names: ".$pname."<BR>";}?>[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/10162-tables-select/#findComment-37885 Share on other sites More sharing options...
corillo181 Posted May 22, 2006 Author Share Posted May 22, 2006 well i found a way.. but if ther eis any other faster way around it.. i'll be happy to know..[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?phpsession_start();include_once 'db.php';$query=mysql_query("SELECT album_id,tra_albums.name,tra_albums.descrive FROM tra_albums ");while($array=mysql_fetch_array($query)){$name=$array['name'];$piname=$array['descrive'];$id=$array['album_id'];$query2=mysql_query("SELECT fotoname FROM tra_photo where album_id='$id'");$fetch=mysql_fetch_array($query2);$potoname=$fetch['fotoname'];echo "album name: ".$name."<BR>"."ablum desc: ".$piname."<BR>";echo " photoname:";$query2=mysql_query("SELECT fotoname FROM tra_photo where album_id='$id'");while($fetch=mysql_fetch_array($query2)){$potoname=$fetch['fotoname'];echo $potoname; }echo "<br>";}?>[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/10162-tables-select/#findComment-37892 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.