Problema selectare tabel

Incerc sa selectez din baza de date cu phpMyAdmin tabelul groups

SELECT * FROM groups

si primesc aceasta eroare asta:

SELECT * FROM groups LIMIT 0, 25
MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'groups LIMIT 0, 25' at line 1

Tabelul meu arata asa:

--
-- Table structure for table `groups`
--

CREATE TABLE `groups` (
  `group_id` int UNSIGNED NOT NULL,
  `group_privacy` enum('secret','closed','public') DEFAULT 'public',
  `group_admin` int UNSIGNED NOT NULL,
  `group_category` int UNSIGNED NOT NULL,
  `group_name` varchar(64) NOT NULL,
  `group_title` varchar(256) NOT NULL,
  `group_description` mediumtext NOT NULL,
  `group_publish_enabled` enum('0','1') NOT NULL DEFAULT '1',
  `group_publish_approval_enabled` enum('0','1') NOT NULL DEFAULT '0',
  `group_picture` varchar(256) DEFAULT NULL,
  `group_picture_id` int UNSIGNED DEFAULT NULL,
  `group_cover` varchar(256) DEFAULT NULL,
  `group_cover_id` int UNSIGNED DEFAULT NULL,
  `group_cover_position` varchar(256) DEFAULT NULL,
  `group_album_pictures` int DEFAULT NULL,
  `group_album_covers` int DEFAULT NULL,
  `group_album_timeline` int DEFAULT NULL,
  `group_pinned_post` int DEFAULT NULL,
  `group_members` int UNSIGNED NOT NULL DEFAULT '0',
  `group_date` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;

--
-- Dumping data for table `groups`
--

INSERT INTO `groups` (`group_id`, `group_privacy`, `group_admin`, `group_category`, `group_name`, `group_title`, `group_description`, `group_publish_enabled`, `group_publish_approval_enabled`, `group_picture`, `group_picture_id`, `group_cover`, `group_cover_id`, `group_cover_position`, `group_album_pictures`, `group_album_covers`, `group_album_timeline`, `group_pinned_post`, `group_members`, `group_date`) VALUES
(1, 'public', 1, 4, 'demo', 'demo', 'test', '1', '0', 'photos/2022/02/demo.jpg', 5, NULL, NULL, NULL, 1, NULL, NULL, NULL, 1, '2022-02-15 22:39:08');

Daca incerc cu

SELECT * FROM `groups`

nu mai primesc eroarea si imi afiseaza tabelul
La alte tabele cum ar fi users, functioneaza fara `
Problema apare doar la tabelul groups si cand incerc sa selectez din php

$query = $db->query("SELECT * FROM groups") or _error("SQL_ERROR_THROWEN");

si aici e neceasar sa pun `

$query = $db->query("SELECT * FROM `groups`") or _error("SQL_ERROR_THROWEN");

Daca schimb numele tabelului il pot selecta fara `

Folosesc Debian 11 cu php 7.4

Daca incerc pe alt host, functioneaza ok
De la ce poate sa fie problema?

https://dev.mysql.com/doc/refman/8.0/en/keywords.html

2 Likes

groups este cuvant rezervat

  • GROUPS (R); added in 8.0.2 (reserved)
6 Likes