[SOLVED] Help Please

13 years 10 months ago #133988 by skosloff
[SOLVED] Help Please was created by skosloff
My SQL skills are minimal, so I would greatly appreciate any help. What i am trying to do is update multiple user listing records when their account expires. The fields and tables are as follows:

TABLE1
user_name
user_id

TABLE2
user_id
listing_id
listing_status

The user_name in these tables is equal to [username] in CB, but the user id numbers are different.

What I think I need to do is find the user_id where user_name=username. But after that I'm lost.

What I need to do is find all listing_ids for that user_id, then set the listing_status of all of those to 'no'. I just don't know how to get there.

Any help would be greatly appreciated. Thank you.

Post edited by: skosloff, at: 2010/06/01 01:58

Post edited by: krileon, at: 2010/06/01 15:35

Please Log in to join the conversation.

13 years 10 months ago #134332 by krileon
Replied by krileon on topic Re:Help Please
If the user_ids don't match then you've no unique identify to establish who is who. You mention user_name is equivalent to username in CB; this should be sufficient for matching users. Please see example below.

[code:1]
UPDATE `TABLE2` SET `listing_status` = 'no' WHERE `user_id` = ( SELECT `user_id` FROM `TABLE1` WHERE `user_name` = '[username]' )
[/code:1]

This should give you the results you're wanting. Please of course perform tests before pushing to a live environment and with all queries make a backup before you execute it!


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

13 years 10 months ago #134395 by skosloff
Replied by skosloff on topic Re:Help Please
That was perfect!

Thank you very much for your assistance!

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.279 seconds