Need Help With SQL Query


Subject: Need Help With SQL Query
Hey guys,

i hope someone can help me with the following, and can provide a sql query for it... my mysql knowlegde is to low to do it on my own...

I need to delete all entries in TABLE_1 where topic_xxx from TABLE_2 is set to "0"... in both tables i have the topic_id field...

something like this, but this did not work:

Code: [Download] [Hide] [Select]
DELETE FROM `phpbb_table_1` WHERE `phpbb_table_2`.`topic_xxx` =0;


can someone help me with this?...

Thanks

Inactive User
Subject: Re: Need Help With SQL Query
A bit difficult without seeing the actual script you want to change, but maybe this will help with what you are trying to drop.

ALTER TABLE phpbb_table_1 DROP topic_xxx;

That should drop the query sub-table, and don't forget to optimise the Db after you've applied it. ;)

Subject: Re: Need Help With SQL Query
Code: [Download] [Hide] [Select]
DELETE FROM `phpbb_table_1` WHERE `phpbb_table_1`.`topic_xxx` = `phpbb_table_2`.`topic_xxx`;

Subject: Re: Need Help With SQL Query
hey guys,

many thanks for your help... but it didnt work...

so i have checked and study the mysql dev again, played a bit and now it works with the following (just for the people how are interested in)

Code: [Download] [Hide] [Select]
DELETE FROM phpbb_table_1
USING phpbb_table_1, phpbb_table_2
WHERE phpbb_table_2.topic_xxx = 0 AND phpbb_table_2.topic_id = phpbb_table_1.topic_id


Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 3.6759s (PHP: 1% SQL: 99%)
SQL queries: 10 - Debug Off - GZIP Enabled