Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8032321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:21:12+00:00 2026-06-05T01:21:12+00:00

Given info about an object: id, user_id, group_id Given info about an user: id_user,

  • 0

Given info about an object: id, user_id, group_id

Given info about an user: id_user, id_loc

I need to get i one query:

  • The name of the user (in table users)

  • The name of the location of the user (in table locs)

  • The name of the group of the object (in table groups)

I am trying like this:

SELECT usuarios.first_name as username
    , usuarios.id as userid
    , usuarios.avatar as useravatar
    , usuarios.id_loc
    , locs.name as locname
    , groups.name as groupname 
FROM usuarios,groups,locs 
WHRE usuarios.id_loc = locs.id 
    AND usuarios.id = 1 
    AND group.id = LIMIT 1

having an error saying

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 ‘AND locs.id = 3 LIMIT 1’ at line 3

What am i doing wrong? can i do this in one query?

-EDIT-

This is the query generator code (php+mysql):

$query_loc_group_user = 'SELECT usuarios.first_name as username,
                                            usuarios.id as userid,
                                            usuarios.avatar as useravatar,
                                            usuarios.id_loc, 
                                            locs.name as locname,
                                            groups.name as groupname
                                     FROM   usuarios,groups,locs
                                     WHRE   usuarios.id_loc = locs.id
                                     AND    usuarios.id = '.$this->id_user.'
                                     AND    group.id = '.$this->id_group.'
                                     LIMIT 1';

In case it helps, i am trying to do in one query this

function get_info(){
    $info;
    $result = cache_query('SELECT first_name,last_name,avatar FROM   usuarios WHERE  id = '.$this->id_user);
    foreach($result as $extra){
        $info['username'] = $extra['first_name'].' '.$extra['last_name'];
        $info['avatar'] = $extra['avatar'];
    }
    $result1 = cache_query('SELECT name FROM locs WHERE  id = '.$this->id_user);
    foreach($result1 as $extra){
        $info['locname'] = $extra['name'];
    }   
    $result2 = cache_query('SELECT name FROM groups WHERE  id = '.$this->id; /*objectid*/
    foreach($result2 as $extra){
        $info['groupname'] = $extra['name'];
    }
    return $info;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:21:13+00:00Added an answer on June 5, 2026 at 1:21 am

    well after some help friend i got to this solution

    SELECT usuarios.first_name,usuarios.last_name,usuarios.avatar,poblacion.poblacion,groups.name as groupname
                                    FROM usuarios LEFT JOIN poblacion ON usuarios.id_loc=poblacion.idpoblacion,
                                         helps LEFT JOIN groups ON helps.id_group = groups.id
                                    WHERE  usuarios.id = '.$this->id_user.' AND groups.id = '.$this->id_group
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 'SessionVisit' table which collects data about user visits. The script for
I need to serialize an object array array<object^>^ in C++/CLI which contains one intPtr
I have a query in Data Access Object DAOComments that joins users table and
Can someone give me some info/background info on how I might go about writing
datetime.datetime.utcnow() Why does this datetime not have any timezone info given that it is
Given is the following class hierarchy: Class Diagram http://img535.imageshack.us/img535/4802/personusermanager.jpg Additional info: The Person class
Given the following lines of code which is using JQTOUCH: $('#customers').bind('pageAnimationEnd', function(e, info){ if
I pasted the code given in this link to a file called md5.js. http://www.webtoolkit.info/javascript-md5.html
I'm trying to get some app info using Apple API, that gives me an
Given the following table: id category_id categorizable_id categorizable_type 66 22 67 Image 72 22

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.