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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:22:23+00:00 2026-06-06T09:22:23+00:00

IF (( SELECT param FROM changes WHERE type = ‘uptime’ AND website_id = 1

  • 0
IF (( SELECT param FROM changes WHERE type = 'uptime' AND website_id = 1 ORDER BY timestamp DESC LIMIT 1 ) != 'up' )
    INSERT INTO changes ( website_id, timestamp, type, param ) VALUES ( 1, NOW(), 'uptime', 'up' )
END IF;

This appears to be an incorrect syntax. How else can I make this work in a single query?

  • 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-06T09:22:24+00:00Added an answer on June 6, 2026 at 9:22 am

    Why are you reading param record outside the query using IF instead of just adding it in the WHERE Condition? If you do it like this then you can just Insert the complete query, if the query returns something your data will be inserted, if your query returns nothing then nothing would be inserted:

    INSERT INTO changes ( website_id, timestamp, type, param )
         SELECT 1, NOW(), 'uptime', 'up'
           FROM changes 
          WHERE type = 'uptime' AND website_id = 1 AND param != 'up' LIMIT 1 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given: code inside a stored proc: select bleh into #tblTemp from FunctionThatReturnsTable('some','params') -- do
This query works fine for me: $query = SELECT p.topnode_id, p.param_key, p.param_value FROM tbl_params
$username_decoded = '<i>marco</i>'; $stmt = $this->db->prepare(SELECT * FROM foo WHERE username=:username); $stmt->bindParam(':username',$username_decoded,PDO::PARAM_STR); $stmt->execute(); $all_fetched
I'm using the chosen UI library to select multiple values for a post param
In following template call <xsl:call-template name=My_Class> <xsl:with-param name=className select=getClassName()/> <xsl:with-param name=baseClassName select=??????/> </xsl:call-template> i
<xsl:call-template name="myfield"> <xsl:with-param name=A/> <xsl:with-param name=B/> <xsl:with-param name=C/> <xsl:if test="not(starts-with(specialTest))"> <xsl:with-param name="TEST" select="'someFunction'"/> </xsl:when>
I have the following in my xslt file: <xsl:param name=predicate select=//Event /> <xsl:apply-templates select=$predicate
$stmt = $dbh->prepare( 'SELECT id, name FROM folders WHERE parent_folder_id = :id' ); $stmt->bindValue(
I have a query that is basically like this: SELECT foo FROM bar where
I have two queries: <cfquery name=getChairReview datasource=#application.dsn#> SELECT* FROM eval_reviews WHERE faculty = <cfqueryparam

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.