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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:59:08+00:00 2026-06-07T11:59:08+00:00

I have a large table on a remote server and want to keep a

  • 0

I have a large table on a remote server and want to keep a copy on the local machine in a flat disk file. If I keep a record of a serial number locally read from the first row of the table then can I issue a SELECT command to return all of the rows in the table if the contents of the column at row id=0 <> my locally stored serial number?

Something like

SELECT * FROM 1_makes WHERE IF id@0<> local_serial

Hope that makes sense

delimiter $$

CREATE TABLE `1_makes` (
  `id` int(11) NOT NULL,
  `make` varchar(20) DEFAULT NULL,
  `allow_global_disc` tinyint(4) DEFAULT NULL,
  `home_text` text,
  `pack_home_text` text,
  `update_ref` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8$$

So what I want is that the entire tables is returned only if the contents of row with id=0 and update_ref is different to the locally stored value.

If I get results then I know the data has changed so I can save it to a local disk file and update the read update_ref

Looks like this is what I need

I have removed the column update_ref and put the update value in the make column @ id=0

SELECT * FROM 1_makes WHERE (SELECT IF(make <> ‘my update number’, 1, 0) FROM 1_makes WHERE id = 0)

This works, just wanted to ask what the numbers 1, 0 relate to in IF(make <> ‘my update number’, 1, 0)

  • 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-07T11:59:09+00:00Added an answer on June 7, 2026 at 11:59 am

    Your case would probably be better served by issuing a separate query. The application would first query the value of the row where id=0, and then proceed based on that.

    However, you could accomplish this with a subquery:

    SELECT *
    FROM 1_make
    WHERE (SELECT IF(update_ref <> :my_number, 1, 0) FROM 1_make WHERE id = 0)
    

    Or an INNER JOIN:

    SELECT t1.*
    FROM 1_make t1
    INNER JOIN 1_make t2
      ON t2.id = 0 AND t2.update_ref <> :my_number
    

    However, if you’re just testing to see if there are results, it’s best just to return the count rather than return the unused values:

    SELECT COUNT(*)
    FROM 1_make
    WHERE (SELECT IF(update_ref <> :my_number, 1, 0) FROM 1_make WHERE id = 0)
    

    Or perhaps even better, use LIMIT to stop after the first row:

    SELECT id
    FROM 1_make
    WHERE (SELECT IF(update_ref <> :my_number, 1, 0) FROM 1_make WHERE id = 0)
    LIMIT 1
    

    Or even better, just use the return value of the IF:

    SELECT IF(update_ref <> :my_number, 1, 0)
    FROM 1_make
    WHERE id = 0
    

    Even better, why store a value for update_ref for every row? Why not move it to its own table:

    SELECT IF(update_ref <> :my_number, 1, 0)
    FROM my_settings
    

    The IF statement return 0, which means false, or 1, which means true.

    Finally, if the id is an incremental value, why not just search for rows where the id is larger than the stored last value instead:

    SELECT id
    FROM 1_make
    WHERE id > :my_number
    LIMIT 1
    

    Also, this doesn’t account for updates. Only, inserts.

    Consider adding a slave server that is replicated from the master server. Then, simply automate backing up the slave server. This is how most backups are done.

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

Sidebar

Related Questions

I have a large table I want to include in a LaTeX document. It
i have a large sql server db, and i want to get the schema
I have large table, with around 200 fields. Around a 100 of those fields
I have large database table, approximately 5GB, now I wan to getCurrentSnapshot of Database
I have a large table of data (that displays test data) that is separated
I have a large table with around half a million rows which is taking
I have a large table (between 74 and 88million rows) which is the middle
I have a large table I imported from an Excel spreadsheet. For five of
I have a large table (~1M rows now, soon ~10M) that has two ranked
I have a large table with a multi-part index. I need to run several

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.