using fields from two tables - mysql

using fields from two tables - mysql

am 04.12.2006 11:40:38 von Gaga

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 ).

Re: using fields from two tables - mysql

am 04.12.2006 12:30:53 von Sean

"Gaga" wrote in message
news:el0ttq$be3$1@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

Re: using fields from two tables - mysql

am 04.12.2006 18:47:14 von unknown

Post removed (X-No-Archive: yes)

Re: using fields from two tables - mysql

am 06.12.2006 16:38:28 von Gaga

> 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 ?

Re: using fields from two tables - mysql

am 07.12.2006 11:11:12 von Sean

"Gaga" wrote in message
news:el6o5e$qis$1@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