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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:51:14+00:00 2026-06-07T12:51:14+00:00

in the following scenario: CREATE TABLE `table1` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT,

  • 0

in the following scenario:

CREATE TABLE `table1` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `text1` varchar(29) NOT NULL,
  `flag` bit(1) DEFAULT NULL,
  `reference` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE ,
  UNIQUE KEY `idx_text` (`text1`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `table1` (id, text1, flag, reference) VALUES
(31486, 'YWXH-D6N4-XXH6', 0, NULL), 
(31487, 'CBH0-UJBC-MFTO', 0, NULL), 
(31488, 'FRQM-E6MW-6VFE', 1, 1657), 
(31489, 'LZOS-EYDT-1BBF', 0, NULL), 
(31490, 'D1XQ-YKAX-XQRC', 0, NULL);

CREATE TABLE `table2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `value1` int(11) NOT NULL,
  `value2` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `value1` (`value1`),
  KEY `value2` (`value2`)
) ENGINE=MyISAM AUTO_INCREMENT=20068 DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;

INSERT INTO table2 (id, value1, value2) VALUES
(1657, 1891, 1748);

-- the tables are shortened from "real" tables, i used SHOW CREATE <table> to create this script.

are the results of the following queries different.
here mysql returns for the record with id 31488 and 31490 the wrong value for the bit-field:

Query 1:

SELECT m.id, m.text1, m.flag, m.reference 
FROM table1 AS m LEFT JOIN table2 AS v ON v.id = m.reference 
GROUP BY m.text1 ORDER BY m.text1 DESC LIMIT 0, 5;

returns the correct result:

id    | text1          | flag | reference
31487 | CBH0-UJBC-MFTO | 0    | NULL
31490 | D1XQ-YKAX-XQRC | 0    | NULL
31488 | FRQM-E6MW-6VFE | 1    | 1657
31489 | LZOS-EYDT-1BBF | 0    | NULL
31486 | YWXH-D6N4-XXH6 | 0    | NULL

while Query 2

SELECT m.id, m.text1, m.flag, m.reference 
FROM table1 AS m LEFT JOIN table2 AS v ON v.id = m.reference 
GROUP BY m.text1 ORDER BY m.text1 DESC LIMIT 0, 4;

returns this:

id    | text1          | flag | reference
31487 | CBH0-UJBC-MFTO | 0    | NULL
31490 | D1XQ-YKAX-XQRC | 1    | NULL
31488 | FRQM-E6MW-6VFE | 0    | 1657
31489 | LZOS-EYDT-1BBF | 0    | NULL

so here is my question:

Im using Joomla CMS, and in the code of the component i can change the whole query except the LIMIT-part.
Joomla add the limit part to the query because of the pagination.

Is there a way to change the query that it works with the LIMIT-command?

oh, my MySQL-Version on Server is 5.1.61 (but this bug still exists on my client v5.5.16)

  • 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-07T12:51:16+00:00Added an answer on June 7, 2026 at 12:51 pm

    Your a) not inserting the data correctly – see the BIT data type docs and b) not selecting the data correctly – see the docs on the Bit-Field Literals

    You need to insert using the following syntax

    INSERT INTO `table1` (id, text1, flag, reference) VALUES
    (31486, 'YWXH-D6N4-XXH6', b'0', NULL), 
    (31487, 'CBH0-UJBC-MFTO', b'0', NULL), 
    (31488, 'FRQM-E6MW-6VFE', b'1', 1657), 
    (31489, 'LZOS-EYDT-1BBF', b'0', NULL), 
    (31490, 'D1XQ-YKAX-XQRC', b'0', NULL);
    

    Then select like this :

    SELECT m.id, m.text1, bin(m.flag), m.reference 
    FROM table1 AS m LEFT JOIN table2 AS v ON v.id = m.reference 
    GROUP BY m.text1 ORDER BY m.text1 DESC LIMIT 0, 4;
    

    Then it all works as expected

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

Sidebar

Related Questions

Given the following: if object_id('MyTable') is null create table MyTable( myColumn int ) Is
I'd like to set up the following database scenario: CREATE TABLE IF NOT EXISTS
In SQL Server 2008, I have the following tables: CREATE TABLE samples (SampleID int,
I have the following scenarios: Scenario: Create a game with valid information Given I
How would I create the following scenario that rails can provide for carrierwave, using
I have the following scenario, I want to create a DataGrid and then populate
I need to create relationships for my entities, whereby I have the following scenario:
How to write Sql or LinqToSql for this scenario? A table has the following
The Requirements I have a following table (pseudo DDL): CREATE TABLE MESSAGE ( MESSAGE_GUID
Currently, I am using the following statement to create a table in an SQLite

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.