Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yadhul's avatar

Mysql Query using laravel

They are two tables : table ' a' and table 'b' and table 'b' have foreign key of table 'a'.

'a' as users table and 'b' as habits table.

for one users they are 5 habits column in habits table.

Now without writing query on habits table..i want to delete the habits all columns.

0 likes
6 replies
CorvS's avatar

@yadhul What do you mean with "without writing query on habits table"? You have to reference the habits table somehow in order to delete rows. Either using Laravel or SQL directly on the database.

Habit::query->delete();
// or
DB::table('habits')->delete();

SQL:

DELETE FROM habits;
yadhul's avatar

@corvs Thanks for your reply.. I need query on users table and delete Habits information. by not using habits table in query. we should not use habits table in query

yadhul's avatar

@sr57 Thank You.. for Answer and Help how in Mysql we can write.

Please or to participate in this conversation.