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

  • SEARCH
  • Home
  • 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 6166833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:24:29+00:00 2026-05-23T22:24:29+00:00

The following query works properly to pull company names from one table into jquery

  • 0

The following query works properly to pull company names from one table into jquery UI autocomplete:

SELECT name FROM company WHERE name LIKE "'. mysql_real_escape_string($_REQUEST['term']) .'%"

The result is looped into an array and encoded to JSON then returned to jquery and displays autocomplete suggestions properly.

I am trying to modify it to pull from two or more tables:

SELECT name
FROM (
SELECT name
FROM company
UNION ALL SELECT CONCAT( fname,  ' ', lname ) 
FROM contact
) AS name
WHERE name LIKE  "'. mysql_real_escape_string($_REQUEST['term']) .'%"

The goal in this case would be to have the autocomplete list include company names and contact names. When I run the query independently of my application (just using PhpMyAdmin console) with a sample search term, it successfully displays the desired results. However in the context of my jquery ui autocomplete form, it does not return any autocomplete suggestions.

I would appreciate any suggestions. Thanks!

EDIT: Sample SQL results

Here is the result I get when I run each of these queries in PhpMyAdmin with test query “mi”.

My original one-table source query:

Generation Time: Jul 20, 2011 at 01:40 AM
Generated by: phpMyAdmin 3.3.9 / MySQL 5.5.8
SQL query: SELECT name FROM company WHERE name LIKE "mi%" LIMIT 0, 30 ; 
Rows: 6

name
[rows removed]

Mr. Wanda’s suggested modification:

Generation Time: Jul 20, 2011 at 01:50 AM
Generated by: phpMyAdmin 3.3.9 / MySQL 5.5.8
SQL query: SELECT temptable.name FROM ( SELECT name as name FROM company UNION ALL SELECT CONCAT( fname, ' ', lname ) as name FROM contact ) AS temptable WHERE temptable.name LIKE "mi%" ; 
Rows: 15

name
[rows removed]

Both are valid SQL that result in a table of one column with rows containing names, but only the first one works in jquery ui. =(

  • 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-05-23T22:24:30+00:00Added an answer on May 23, 2026 at 10:24 pm

    See bold text below.

    SELECT temptable.[name]
    FROM (

    SELECT name as [name]
    FROM company

    UNION ALL

    SELECT TRIM(ISNULL(fname,”) + ‘ ‘ + ISNULL(lname,”)) as [name]
    FROM contact

    ) AS temptable
    WHERE
    temptable.name LIKE “‘. mysql_real_escape_string($_REQUEST[‘term’]) .’%”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following query which works fine for me except one problem SELECT
I have the following query that works well. SELECT DISTINCT city,region1,region2 from static_geo_world where
i've been using the following query: select LEN(columnname) as columnmame from dbo.amu_datastaging This works,
This has to be obtained from a remote machine. The following query works not
I have the following query which works: SELECT ?page ?lat ?long (bif:st_distance(?geo, bif:st_point(42.883, -72.8981)))
I have the following query. It works just fine but I need to pull
I have the following query: SELECT * FROM ( SELECT * FROM View_ExecutiveForecastReport WHERE
I have the following query: $sqltext = SELECT Score FROM HighScore . WHERE fbID='$_POST[fbID]'
The following query works on Oracle 10.2.0.1.0 on windows,but doesn't work on Oracle 10.2.0.2.0
The following query works as long as I can add DataRelations. However, the relation

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.