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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:18:34+00:00 2026-06-11T13:18:34+00:00

Just need some help with a SQL statement, I have a table that has

  • 0

Just need some help with a SQL statement, I have a table that has a bunch of user data, currently I am getting all the data by rowid descending. However I need to modify the way the data is displayed as follows:

The table has a field in which users can specify their own value or the can choose the default value. When choosing the default value the field is auto populated with a “randomstring_standardefaultvalue”.

So basically I need to select all the data in which the user did not choose the defaultvalue and have them order descending and then grab all the rows in which the user selected the defaultvalue and populate them after the first set of data sorted by descending rowid.

My current SQL Looks like this,

$query = "SELECT * FROM userform ORDER BY _rowid_ DESC LIMIT {$offset}, {$pl};";

Table Data:

rowid  date  username  defaultoruniquevalue  member  etc...

Help would be greatly appreciated.
Thank You!

ANSWER:

SELECT *, IF(defaultoruniquevalue LIKE CONCAT('%','defaultstring','%'), 1, 0) AS uses_default
FROM table
ORDER BY uses_default ASC, _rowid_ DESC
LIMIT {$offset}, {$pl
  • 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-11T13:18:35+00:00Added an answer on June 11, 2026 at 1:18 pm

    I hope I’m understanding your question correctly, but it sounds like you need to add a WHERE clause to your query:

    SELECT *
    FROM userform
    WHERE defaultoruniquevalue != "default"
    ORDER BY rowid DESC
    LIMIT {$offset}, {$pl}
    

    Edit

    SELECT *, IF(defaultoruniquevalue LIKE '%_default', 1, 0) AS uses_default
    FROM userform
    ORDER BY uses_default ASC, rowid DESC
    LIMIT {$offset}, {$pl}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just need some quick clarification I have 2 Queries in my Access Database that
I need some help converting the SQL found below to an equivalent LINQ statement
I need some help sorting my score value's of my sql database <table border
I need some help figuring out and SQL Statement. I know what I want
I just need some help to finish turning this SQL : SELECT us.name, pt.task,
Just need some help/advice with SQL Server 2005 and Visual Studio 2005. Basically I
I got some code off the Internet and now I just need help to
I just need some clarification on variables A normal variable has 2 parts to
Im just starting with localization today and need some information. I have a project
Suppose we have some data that looks like so R_Id Nm Base Dest Proj

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.