homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Deleting from multiple tables
query issues in php

Msg#: 4430443 posted 10:42 pm on Mar 17, 2012 (gmt 0)

Course table
cid(course id)

course_student table
sno(student id)
cid(course id)

Student table
sno(student id)

Hello peeps! I need your help on this one... the query i need is when i delete the record from course table it should delete all the records where that cid = sno in course_student(without leaving orphans) and where sno of course_student = sno of student at once! (php5 and mysql)




Msg#: 4430443 posted 11:55 pm on Mar 17, 2012 (gmt 0)

$result = " SELECT * FROM course, course_student, student WHERE course.cid = course_student.cid AND course_student.sno = student.sno AND course.cid = '$cid'";
$result = "DELETE course,course_student,student FROM course LEFT JOIN course_student ON course.cid = course_student.cid LEFT JOIN student ON course_student.sno = student.sno WHERE course.cid = '$cid'";

Sorted it out myself cheers!


WebmasterWorld Administrator coopster us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4430443 posted 12:44 am on Apr 6, 2012 (gmt 0)

Good for you femiot! Glad you got it sorted. Now you can dig into a neat little database feature called "triggers" ... always more to learn :)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved