using fields from two tables - mysql

If i pull data from one table and if i need just one field ( lets say user
ID ) from other table, what should i do to make this work. I want to read
all data from one table and then make the comparation of the passed data and
the user ID data, in other table....( user id is in users table and all
other data is in data table ).
Gaga [ Mo, 04 Dezember 2006 11:40 ] [ ID #1556918 ]

Re: using fields from two tables - mysql

"Gaga" <rg2006 [at] hotmail.com> wrote in message
news:el0ttq$be3$1 [at] ss408.t-com.hr...
> If i pull data from one table and if i need just one field ( lets say user
> ID ) from other table, what should i do to make this work. I want to read
> all data from one table and then make the comparation of the passed data
> and
> the user ID data, in other table....( user id is in users table and all
> other data is in data table ).
>
>

Is there something in common in the two tables?

Perhaps you could post an example of the table structures.

Sean
Sean [ Mo, 04 Dezember 2006 12:30 ] [ ID #1556921 ]

Re: using fields from two tables - mysql

Post removed (X-No-Archive: yes)
Notifier Deamon [ Mo, 04 Dezember 2006 18:47 ] [ ID #1556924 ]

Re: using fields from two tables - mysql

> If I understand you correctly you have two tables "users" and "data". If
you
> have the userid as the primary key in the users, you can use that id as a
> secondary key in your data table. That way you can build a relationship
between
> the two tables and can group the information correctly in your SQL.

-- I dont know how to make this in mysql :-(

Im reading data from one table. After i have read selected data i want to
write this data into second table and delete old data in the first table. I
want to make simple "data move" from first to second table. I need to make
all this on one php page. How ?
Gaga [ Mi, 06 Dezember 2006 16:38 ] [ ID #1559327 ]

Re: using fields from two tables - mysql

"Gaga" <rg2006 [at] hotmail.com> wrote in message
news:el6o5e$qis$1 [at] ss408.t-com.hr...
>> If I understand you correctly you have two tables "users" and "data". If
> you
>> have the userid as the primary key in the users, you can use that id as a
>> secondary key in your data table. That way you can build a relationship
> between
>> the two tables and can group the information correctly in your SQL.
>
> -- I dont know how to make this in mysql :-(
>
> Im reading data from one table. After i have read selected data i want to
> write this data into second table and delete old data in the first table.
> I
> want to make simple "data move" from first to second table. I need to make
> all this on one php page. How ?
>
>
>

You should be able to do this in two steps. This is very basic and if you
are going to guarantee the validity of the transfer you would need to do
some more validation to ensure that noone (or nothing) adds a record to
table1 between these two commands.

insert table2 (field1, field2, field3)
values select field1, field2, field3 from table1 where field3 = 'criteria'

delete * from table1 where field3 = 'criteria'

Sean
Sean [ Do, 07 Dezember 2006 11:11 ] [ ID #1560557 ]
PHP » alt.php.sql » using fields from two tables - mysql

Vorheriges Thema: Accessing MySql in PHP on Yahoo! Web hosting
Nächstes Thema: arranging data results in multiple tables.