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 6975307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:21:05+00:00 2026-05-27T17:21:05+00:00

I have this query: $result = mysql_query(SELECT id,pic0,bio,url FROM .$table. WHERE id LIKE ‘%custom%’

  • 0

I have this query:

$result = mysql_query("SELECT id,pic0,bio,url FROM ".$table." WHERE id LIKE '%custom%' || ( category IN ('cat1') AND model = 'bmw'");`

And I am displaying them in a loop like:

while ($slice = mysql_fetch_assoc($result)){ }

Is there a way to firstly display the records from: WHERE id LIKE '%custom%'

And after display the records from: || ( category IN ('cat1') AND model = 'bmw'");

Ty for your answer.

Here is an updated sql code which I did to be sure the duplicates are removed automaticly:

(
SELECT 1 AS sort_col, performerid, pic0
FROM `cronjob_reloaded`
WHERE performerid IS NOT NULL
)
UNION (

SELECT 2 AS sort_col, performerid, pic0
FROM `cronjob_reloaded`
WHERE performerid IS NOT NULL
AND category
IN (
'Girl'
)
)
ORDER BY sort_col 

And they are not. The first select gets the same result as the select nr two, but mysql shows me all the rows combined.

  • 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-27T17:21:05+00:00Added an answer on May 27, 2026 at 5:21 pm

    you could use a union

    $result = mysql_query("(SELECT 1 as sort_col,id,pic0,bio,url FROM ".$table." WHERE id LIKE '%custom%') UNION  (SELECT 2 as sort_col,id,pic0,bio,url FROM ".$table." WHERE  category IN ('cat1') AND model = 'bmw') order by sort_col";
    

    edit: removed the warning about duplicates (according to mysql union docs, dupes are removed automatically), added sort_col to make sure the order is kept.

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

Sidebar

Related Questions

Hey there, why does this code not work? $qry = mysql_query(SELECT performerid,pic0 FROM .$table.
so I have this query: SELECT COUNT( * ) AS cnt FROM table WHERE
i have a query that goes like this: $get_feed_amount = mysql_query( SELECT COUNT(*) as
I have this query to use in PHP: mysql_query(select count(*) from registeredUsers where email=.$_SESSION[username]);
I have this MySQL query that I'd like to optimize: SELECT min(`topic_id`) FROM `gallery_topics`
I have this code: $result = mysql_query(SELECT * FROM quote ORDER BY RAND() LIMIT
lets say i have this query SELECT tags FROM myTABLE; and the result of
I have a Linq to Entities query like this one: var results = from
I have this query: SELECT page.id, revision.title, revision.number FROM page INNER JOIN revision ON
I have the following code: (query added) $weight_table = mysql_query (SELECT * FROM .$prefix.weight

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.