Closed Thread Icon

Topic awaiting preservation: Select fields from diferents tables (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12246" title="Pages that link to Topic awaiting preservation: Select fields from diferents tables (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Select fields from diferents tables <span class="small">(Page 1 of 1)</span>\

 
Wakkos
Maniac (V) Mad Scientist

From: Azylum's Secret Lab
Insane since: Oct 2000

posted posted 06-02-2002 22:08

Hola!
I got a forum, i have a table for initial messages and another for the reply. I have the same fields in both tables:
table posts
Imagenes

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 06-03-2002 00:30

im not sure but try this:

$query_showPosts = "
SELECT imagenes.posts,user_name.posts,mensaje.posts,imagenes.reply,user_name.reply,mensaje.reply
FROM posts,reply ";


GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 06-03-2002 00:31

no. stupid me! it has to be the other way round:


$query_showPosts = "
SELECT posts.imagenes,posts.user_name,posts.mensaje,reply.imagenes,reply.user_name,reply.mensaje
FROM posts,reply ";

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 06-03-2002 05:46

Using a join like Grumble suggests will probably not give you what you want as it will combine rows in every possible way giving you m * n rows where m, n are the number of rows in table1, table2.

Just a suggestion, but it might make more sense to have one table and just have an integer field that contains the id number of the post that it is a reply to. If it is not a reply just set the field to 0. That way you can use a simple query to get all the posts or all the replies to specific post.

-jiblet

[This message has been edited by jiblet (edited 06-03-2002).]

Wakkos
Maniac (V) Mad Scientist

From: Azylum's Secret Lab
Insane since: Oct 2000

posted posted 06-10-2002 19:56

Jiblet, it's a special thing, and the field in each table are totally different.....

A sig should be here.....
But is not.

« BackwardsOnwards »

Show Forum Drop Down Menu