Date: 10/13/00
- Next message: Tom: "[PHP-DB] php and sybase"
- Previous message: Meir kriheli: "Re: [PHP-DB] Some SQL/ODBC admin tool for WIN?"
- Maybe in reply to: CESBRON S.: "[PHP-DB] SQL Question"
- Next in thread: Ermanno Iannacci: "Re: [PHP-DB] SQL Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
There are different SQL programming styles you could use, an easy way
to do it is using sub-queries (not supported on current version of
MySQL) so until it is supported I usually do a outer join to select the
records you dont want in the other table and i loop through the records
making a string variable and then feeding it to another sql statement
that deletes from the desired table.
select a.login from table2 as a left join table1 as b on a.login =
b.login where b.login is null
loop through results doing this
$str = $str . ",'$row->login'"; (for the exception of the first time
where you should use "$row->login" only
delete from table2 where login in ($str)
That should do the trick, but ask around for more info because I'm new
to sql and php also. Hope this helps
> Table 1
> +---------+-----------+
> + Login + Password +
> +---------+-----------+
> + steph + toto +
> + yann + titi +
> +---------+-----------+
>
> Table 2
> +---------+-----------+-------------+--------------+ ...
> + Login +first name + second name + Address + ...
> +---------+-----------+-------------+--------------+
> + steph + xxxxxx + yyyyyyyyyy + zzzzzzzzzzzzz +
> + isab + xxxxxx + yyyyyyyyyy + zzzzzzzzzzzzz +
> +---------+------------+------------+--------------+
>
>
> I'd like to find a SQL statement to delete the second row (isab) from
> Table
> 2 depending on the login field.
>
> Could anyone help please ?
>
> Thanks
> Stéphane
>
> Stéphane Cesbron
> Chargé du développement Internet/Intranet
>
> AUDENCIA
> Nantes.Ecole de Management
> 8 route de la Jonelière
> B.P. 31222
> 44312 Nantes Cedex 3
> Tél : 02.40.37.34.47
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe <email protected>
> For additional commands, e-mail: php-db-help <email protected>
> To contact the list administrators, e-mail:
> php-list-admin <email protected>
>
=====
Ernesto Young Han
www.zonaflash.com
H:(718)672-8523 W:(212)820-7035 C:(646)418-7766
41-15 76th Street 2nd Fl
Elmhurst, NY 11373
Palavra do Dia:
"Portanto, para mim o viver e' Cristo, e morrer e' lucro"
__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Tom: "[PHP-DB] php and sybase"
- Previous message: Meir kriheli: "Re: [PHP-DB] Some SQL/ODBC admin tool for WIN?"
- Maybe in reply to: CESBRON S.: "[PHP-DB] SQL Question"
- Next in thread: Ermanno Iannacci: "Re: [PHP-DB] SQL Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

