Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-08-2009, 12:30 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Easy Database Query Question

Hey all,

This is self explanatory I guess. Can someone please fix this for me?? I know I am messing up with the Where clause...


HTML Code:
SELECT *
FROM userfield AS userfield
LEFT JOIN user AS user ON (user.userid = userfield.userid)
WHERE user.usergroupid = 15 AND user.userfield = 19, 20, 7, 12, 13, 18, 14, 15, 16, 17,
Thanks much

webdevoman

--------------- Added 07 Sep 2009 at 23:12 ---------------

I think I have it-- Is this it??

PHP Code:
SELECT *
FROM userfield AS userfield
LEFT JOIN user 
AS user ON (user.userid userfield.userid)
WHERE user.usergroupid 15 AND user.userfield '19' and '20' and '7' and '12' and '13' and '14' and '15' and '16' and '17' and '18'
This is not it either--

Error


SELECT *
FROM userfield AS userfield
LEFT JOIN user AS user ON ( user.userid = userfield.userid )
WHERE user.usergroupid =15
AND user.userfield = '19'
AND '20'
AND '7'
AND '12'
AND '13'
AND '14'
AND '15'
AND '16'
AND '17'
AND '18',
LIMIT 0 , 30
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
LIMIT 0, 30' at line 4
Reply With Quote
  #2  
Old 09-08-2009, 03:27 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What is it you want in words? You can't mean that you want user.userfield to equal 19 and to equal 20 and to equal to 7 and equal to ..... especially since there is no column in the user table called userfield. So, why don't you tell us in words what you want because what you have so far is not 'self explanatory'.
Reply With Quote
  #3  
Old 09-08-2009, 03:50 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK-

Thanks

the numbers are in the "userfield" table and I meant "field20" etc--These are custom profile fields..

I am exporting data from the userfield Table but only from usergroup 15- This part I have already..

Additionally I want to narrow this dump down to eliminate some of the userfield fields... I only want the fields dumped that I listed above..

Does this make more sense???

I am trying to dump some member info into text format. That is the the main goal here..

Thanks and sorry for my miscommunication...
Reply With Quote
  #4  
Old 09-08-2009, 04:05 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It sounds like the select part is wrong then. Perhaps more like this?

Code:
SELECT field19, field20, field7, field12 etc....
FROM userfield as userfield
LEFT JOIN user AS user ON (user.userid = userfield.userid)
WHERE user.usergroupid = 15
Reply With Quote
  #5  
Old 09-08-2009, 04:07 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, That looks a bit closer to what I have been working on the last few minutes.. I will give this a shot and thank you soo much for the help..
Reply With Quote
  #6  
Old 09-08-2009, 04:08 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
SELECT userfield.userid
     , userfield.field7
     , userfield.field12
     , userfield.field13
     , userfield.field14
  /* , you get the idea */
  FROM userfield
INNER
  JOIN user
    ON user.userid = userfield.userid
 WHERE user.usergroupid = 15
Reply With Quote
  #7  
Old 09-08-2009, 04:14 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynn, close but I think SirAdrian has it.. I will let you know in a few and thank you both. it was really important that I finish this tonight and I would have been trying alterations of this for hours and hours..lol

I will run this and get back in a few..

Thanks again..

Yeah, that was it SirAdrian.... Geez, looking at my earlier tries, I was waaay off! I guess all of these attempts has taught me a little something so I guess the time spent wasn't a total waste. lol

At one point I was soo close. I had everything correct but instead of userfield.field## --I just had field##--I thought that because I clarified the userfield already I didn't have to clarify it again. When I ran that query it was trying to pull field## from the usergroup table and not the userfield table...

I understand now..

You both are great.. I appreciate it. I guess it is a good thing that I will be starting a course in mysql in a few weeks.. I am in dire need.

webdevoman
Reply With Quote
  #8  
Old 10-18-2009, 10:18 PM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I Just posted a new thread on this so this can be deleted if needed....

Hey all,

This worked great but now I have to add usernames and e-mail addresses to this? Can anyone save me some time on this??

Thanks
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:30 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04404 seconds
  • Memory Usage 2,245KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete