943,923 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Marked Solved
  • Views: 4857
  • MySQL RSS
You are currently viewing page 7 of this multi-page discussion thread; Jump to the first page
Nov 25th, 2008
0

Re: Pulling related data from relational dB re: thread: Problems with a many-to-many inse

OK I will try it but the relationship is a one-to-many from users to uas ... yes? It would not make sense that a user can exist and not have a link to an airport or service?? I will try deleting something now.
Reputation Points: 10
Solved Threads: 1
Junior Poster
filch is offline Offline
132 posts
since Nov 2008
Nov 25th, 2008
0

Re: Pulling related data from relational dB re: thread: Problems with a many-to-many inse

OK .. I used the following:

DELETE * FROM `userairportservices` WHERE `usr_id_users` = 5

and it says I have an error in my syntax. I don't think I do. But I bet if I delete the user it will delete the uas entries for that user as well.
Reputation Points: 10
Solved Threads: 1
Junior Poster
filch is offline Offline
132 posts
since Nov 2008
Nov 25th, 2008
0

Re: Pulling related data from relational dB re: thread: Problems with a many-to-many inse

well it doesn't make sense as far as the user won't have any services, from the database side it just means there is a user, just no services saved yet

yes users -> uas 1..x

it means a user has been created, but no services have been created
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Nov 25th, 2008
0

Re: Pulling related data from relational dB re: thread: Problems with a many-to-many inse

So, I think you are still saying that we should be able to delete directly from the UAS table ... yes? So, what is the purpose of constraints?

Do I have to alter the tables/database or something?
Reputation Points: 10
Solved Threads: 1
Junior Poster
filch is offline Offline
132 posts
since Nov 2008
Nov 25th, 2008
0

Re: Pulling related data from relational dB re: thread: Problems with a many-to-many inse

constraints will do what you are meaning, delete from the user table then it will propagate to other tables that reference that user

lol did i put delete *, just use delete from without the *
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Nov 25th, 2008
0

Re: Pulling related data from relational dB re: thread: Problems with a many-to-many inse

OK .... you are correct ;-) I guess the problem was the * all along because I used the same SQL when I was trying it before.

So, if there is a match, delete from userairportservices where usr_id = $usid

else insert

sound about right?
Reputation Points: 10
Solved Threads: 1
Junior Poster
filch is offline Offline
132 posts
since Nov 2008
Nov 25th, 2008
0

Re: Pulling related data from relational dB re: thread: Problems with a many-to-many inse

no need to do a check, just run the delete, it won't matter if there is a match or isn't

then just run inserts
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Nov 25th, 2008
0

Re: Pulling related data from relational dB re: thread: Problems with a many-to-many inse

Actually, this will no longer be an if/else statement will it? We just need to test if there is a record matching the user, airport etc and then delete all of those. Then do an INSERT. I think that is about right.
Reputation Points: 10
Solved Threads: 1
Junior Poster
filch is offline Offline
132 posts
since Nov 2008
Nov 25th, 2008
1

Re: Pulling related data from relational dB re: thread: Problems with a many-to-many inse

actually no need to check the uas table at all, just delete, then insert

you are correct, check user table i guess from a login or whatever that is, then no need to check anything against uas table except when displaying the form, on submit delete and insert

also i normally wouldn't suggest this, but i think it is appropriate here, we don't need a uas_id on uas table, it is always being deleted and never referenced, you can keep it, no big deal, its just not of use i see yet, but maybe keep it if you think you will need it later
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Nov 25th, 2008
0

Re: Pulling related data from relational dB re: thread: Problems with a many-to-many inse

OK ;-)))))))

That's got it!!!!

Now all I have to do is figure out how to disable the services checkboxes until the user clicks on an airport checkbox ... but that is another issue ;-)

You have a night full of beer if you ever get here to Toronto. If you have a book wish list just let me know. You have been a huge help, a patient man and an all around great guy.

Seriously ... thank you very very much for your kind help.

Dave
Reputation Points: 10
Solved Threads: 1
Junior Poster
filch is offline Offline
132 posts
since Nov 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: Which is better? Tons of separate tables with a little data or one big table?
Next Thread in MySQL Forum Timeline: update in steps? is it possible ?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC