Operand should contain 1 column(s) if-clause

164
September 20, 2018, at 12:10 PM

I do not understand why this query is wrong. I tried the true and false queries alone and it works, but when I put them in the if-clause it does not. Thanks in advance for help :)

SELECT 
IF ( 
    (SELECT useronline FROM wp_livechat ORDER BY id DESC LIMIT 1) = 1
    , 
    (SELECT *
     FROM wp_livechat
     WHERE id >= (SELECT id 
                  FROM wp_livechat
                  WHERE useronline = 0
                  ORDER BY id DESC
                  LIMIT 0, 1)
     AND id <= (SELECT id 
                FROM wp_livechat
                WHERE useronline = 1
                ORDER BY id DESC
                LIMIT 0, 1)
    ),
    (SELECT *
     FROM wp_livechat
     WHERE id >= (SELECT id 
                  FROM wp_livechat
                  WHERE useronline = 0
                  ORDER BY id DESC
                  LIMIT 1, 1)
     AND id <= (SELECT id 
                FROM wp_livechat
                WHERE useronline = 0
                ORDER BY id DESC
                LIMIT 0, 1)
    )
);

EDIT: This is the table: https://ibb.co/huri6e

And i want to get the messages from the last useronline = 0 to the forelast useronline = 0. And if the last entry is useronline = 1 then i want to retrieve the messages from the last entry with useronline = 1 to the last entry with the useronline = 0.

Rent Charter Buses Company
READ ALSO
connecting javaprogram to mysql database

connecting javaprogram to mysql database

execute update is a method in another classthere seem to be whats the wrong with this code segment? database is not updating!!

156
MySQL INSERT INTO SELECT SET

MySQL INSERT INTO SELECT SET

I'm trying to copy a table to the columns of a different table but the date fields are not valid(Date are like '00000000') for some of the columns so I'm trying to check if the date is valid and I'm trying to set it NULL if soExample,

184
How do I configure and access SQL Server from ASP.NET Core in Google Cloud Platform [on hold]

How do I configure and access SQL Server from ASP.NET Core in Google Cloud Platform [on hold]

I have a requirement to test in Google Cloud Platform an ASPNET Core Razor app that currently runs in Microsoft Azure with a SQl Server database

176
Wordpress database accidentally changed URL

Wordpress database accidentally changed URL

I have accidently changed my wordpress URL and Site URL in my wordpress adminNow I cannot access my backend of the site, its throwing a 404 error

110