Select Statement Alone Without From to Check Integrity, Get Date, etc

According to Sams Teach Yourself SQL, if you just use SELECT without FROM, you can do the following:

  1. Get information such as current date
    SELECT CURDATE(0) ; == (should return current date)

  2. Do a calculation
    SELECT 4*5 ; ==(should return value of 20)

3.See if functions are working properly
SELECT RTRIM("abc "); ==(should return string abc).

However, in LibreOffice 5.4 BASE, when I use select alone, I get “Syntax error in SQL statement”.

Any thoughts? Thanks!

Hello,

As mentioned in a previous answer:

Anytime you are dealing with SQL for a specific database, it is proper to use the Guide for that particular version.

So the question becomes, what database is the guide you refer to based upon?

Some quick testing shows that statement to work in newer versions of MySQL and PostgreSQL but not in HSQLDB.

Even though something works in one database doesn’t mean it will work in another. Even if standards are followed within a database, which implementation of standards can mean a difference in capabilities. Databases also include non-standard functions at their discretion. If so, this is usually noted within the documentation for that database for that version.

As a final note about a lot of those guides, see this post → Teach Yourself Programming in Ten Years.

Also (as also commented on in your question):

If this answers your question please tick the :heavy_check_mark: (upper left area of answer). It helps others to know there was an accepted answer.

Thanks for your response. I have downloaded the guide which ( I hope) is correct for my version. Again, here is the version of Libre Office:
Version: 5.4.0.3 (x64)
Build ID: 7556cbc6811c9d992f4064ab9287069087d7f62c
CPU threads: 2; OS: Windows 6.1; UI render: default;
Locale: en-US (en_US); Calc: group

BTW, I do have some programming experience, but not (obviously) in SQL. I actually have a background in chemistry, but for the work I am doing I need to be able to learn and use SQL

I just read your newest comment on the first post. The guide you linked to does seem to be correct for my version of SQL.

BTW, I can not find the check sign to show that the question is answered. I just can’t find it. Is it near the facebook and twitter icon at the top. Just can’t find it.

By ‘the guide’ I hope you mean the linked one in the last answer. To me, the book you have is a waste. There are many sites on-line which give the same, if not more, information. See → w3schools for one.

Also note, the HSQLDB embedded v1.8 in your LO (and all recent ones) is VERY old. It is being replaced by Firebird embedded. This is currently available with experimental features turned on - From menu - Tools->Options. Under LibreOffice->Advanced.

The check mark is just to the LEFT of the upper part of each answer. The up & down caret just above this is to upvote or downvote an answer if you think this is a good/not good answer. These things are indicators to others on the contents of the answer. It also increases/decreases ‘Karma’. See → faq.

This post clearly show how to mark → How do I mark the best answer to my question on this site? [closed]

Hi,

Now I do see the appropriate checkmark.
I have one more question: I will be using SQL 2012 when I have learned enough to be operational. Would, in your experience, the free download of SQL 2008 on cnet be more closely aligned with what I will be using than the HSQLDB I am currently using through LibreOffice? Any thoughts would be helpful. Tx!

SQL Server 2008 Express (you can get directly from Microsoft - no cost) in your instance would be better that using HSQLDB. It is still not SQL 2012 which will have more features and functionality. At least it would be closer. Best to always educate yourself using the actual product you will end up with.

Great. It looks like I can even download SQL 2012 Express for free. That would be the closest free version I can get. Once I know some basic programming, I will be able to access the SQL 2012 database itself on site. For now, I am learning the basics at home, and need a free version. Thanks for your help!!!