Ask Your Question
0

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

asked 2018-10-11 03:30:14 +0200

ManitobaMoose2 gravatar image

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)

  1. 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!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-10-11 04:02:25 +0200

Ratslinger gravatar image

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.

edit flag offensive delete link more

Comments

Also (as also commented on in your question):

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

Ratslinger gravatar imageRatslinger ( 2018-10-11 04:09:19 +0200 )edit

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

ManitobaMoose2 gravatar imageManitobaMoose2 ( 2018-10-11 04:19:09 +0200 )edit

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.

ManitobaMoose2 gravatar imageManitobaMoose2 ( 2018-10-11 04:26:39 +0200 )edit

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.

Ratslinger gravatar imageRatslinger ( 2018-10-11 04:28:18 +0200 )edit

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.

Ratslinger gravatar imageRatslinger ( 2018-10-11 04:37:08 +0200 )edit
Ratslinger gravatar imageRatslinger ( 2018-10-11 04:43:34 +0200 )edit

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!

ManitobaMoose2 gravatar imageManitobaMoose2 ( 2018-10-12 20:45:49 +0200 )edit

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.

Ratslinger gravatar imageRatslinger ( 2018-10-12 21:10:23 +0200 )edit

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!!!

ManitobaMoose2 gravatar imageManitobaMoose2 ( 2018-10-12 23:05:08 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-10-11 03:30:14 +0200

Seen: 13 times

Last updated: Oct 11