Unable to run SQL query and selecting fulltext Topic is solved

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
CptBlisterButt
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Thu Sep 15, 2011 2:50 am

Unable to run SQL query and selecting fulltext

Post by CptBlisterButt » Thu May 13, 2021 12:39 am

Hello,

I'm trying to run SQL query from the MariaDB console and select a full article text as per fulltext field in the following table:

Code: Select all

+------------------+---------------------+------+-----+---------------------+----------------+
| Field            | Type                | Null | Key | Default             | Extra          |
+------------------+---------------------+------+-----+---------------------+----------------+
| id               | int(10) unsigned    | NO   | PRI | NULL                | auto_increment |
| asset_id         | int(10) unsigned    | NO   |     | 0                   |                |
| title            | varchar(255)        | NO   |     |                     |                |
| alias            | varchar(400)        | NO   | MUL |                     |                |
| introtext        | longtext            | NO   |     | NULL                |                |
| fulltext         | longtext            | NO   |     | NULL  
For example the following SQL query will show introtext without any issues:

Code: Select all

select introtext from  vs152_content where id=126;
However, when attempting to select fulltext and SQL query results in error:

Code: Select all

select fulltext from  vs152_content where id=126;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'fulltext from  vs172_content where id=126' at line 1
Server: Server version: 10.3.27-MariaDB-0+deb10u1 Debian 10

Can somebody please provide me with some hints on what I'm doing wrong?

thank you

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13531
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Unable to run SQL query and selecting fulltext

Post by toivo » Thu May 13, 2021 1:19 am

FULLTEXT is a reserved word in both MariaDB and MySQL.

Use backticks and it will work:

Code: Select all

select `fulltext` from  vs152_content where id=126;
Toivo Talikka, Global Moderator

CptBlisterButt
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Thu Sep 15, 2011 2:50 am

Re: Unable to run SQL query and selecting fulltext

Post by CptBlisterButt » Thu May 13, 2021 1:36 am

toivo wrote:
Thu May 13, 2021 1:19 am
FULLTEXT is a reserved word in both MariaDB and MySQL.

Use backticks and it will work:

Code: Select all

select `fulltext` from  vs152_content where id=126;
Worked, thank you..Just to be complete, why the example worked without ` ` with introtext and not fulltext. I have assumed that since they both have same field type it should also work the same for both.

thank you again..

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13531
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Unable to run SQL query and selecting fulltext

Post by toivo » Thu May 13, 2021 3:04 am

INTROTEXT is not a reserved word, therefore it is syntactically unambiguous and consequently it does not require backticks.

Ref. MariaDB Reserved Words
Toivo Talikka, Global Moderator


Post Reply

Return to “Administration Joomla! 3.x”