SQL Help

13 years 4 months ago #150241 by jogoeire
SQL Help was created by jogoeire
Hi Community,
I wonder could someone help me with an SQL query! Heres what im trying to do... print to a webpage all member names and the value of the following custom fields.. cb_racedate, cb_position,cb_racename,cb_racetime. So a line on my page will look something like this:

Name Date Pos Race Name Time
John Smith 12/2/10 3 New York race 3.33
Pat Reilly 22/6/10 5 Chicago race 2.33

I was hoping someone might be able to give me the query so I don't have to spend the next couple of days learning SQL... its on my todo list but im pressed right now.
I think I can figure out the PHP but so just the query would be fantastic.

Thanks community. Rob

Please Log in to join the conversation.

13 years 4 months ago #150250 by krileon
Replied by krileon on topic Re:SQL Help
Believe this should be a simple select query if that's what you're wanting. Of course you'd need to output it as an object/array if you intend to use it in PHP. Query is as follows.

[code:1]
SELECT b.`name` AS 'Name'
, a.`cb_racedate` AS 'Date'
, a.`cb_position` AS 'Pos'
, a.`cb_racename` AS 'Race'
, a.`cb_racetime` AS 'Time'
FROM `#__comprofiler` AS a
LEFT JOIN `#__users` AS b
ON a.`user_id` = b.`id`
[/code:1]

If you need formatting of course that'd need to be done with a more complex query. You can find information on MYSQL queries for formatting results here . You can also find some great SQL tutorials here .


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 3 months ago #151139 by jogoeire
Replied by jogoeire on topic Re:SQL Help
Thanks so much! That really helped. Anyone following me in my footsteps I had to rename the tables in my query to jos_ instead of #___

Ive also since stopped being a girly man and went and learned my php/sql... well im in the process anyway :) I can recommend http://www.tizag.com/sqlTutorial/ to others.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.415 seconds