Can't view table in phpmyadmin - mysql

When using phpmyadmin I can't display the table wp_postmeta.
No matter if I click on the table on the sidebar or do a manual query, phpmyadmin automatically adds inner join `wp_posts` onpost_id=`wp_posts`.id and returns the following error:
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 'inner joinwp_posts onpost_id=wp_posts.id
LIMIT 0, 25' at line 1
It only does this on this specific table.
How do I prevent phpmyadmin from doing this and where could it came from?

Mysql is a php application and as every application may have some problems or bugs, which query you have tested to retrieve the data? this?
SELECT * FROM wp_postmeta
Maybe your wp_postmeta table is corrupted, you can try to fix it with phpmyadmin function, but before doing this be sure to do a full database backup
Here you can find where you can repair the table:
https://www.siteground.com/tutorials/phpmyadmin/repair-optimize-database/

Related

MySQL vs MariaDB - ddl - setting default for time field

I've got table products, and want to add column with type time.
I've got statement as follows:
ALTER TABLE products ADD openTime1 TIME DEFAULT TIME(now());
it works on MariaDB, but it doesnt work on Mysql.
On mysql it produces Error -
[42000][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 '(now())' at line 1
Can someone tell me why? whats wrong here? I thought that this should be the same.
In MySQL the expression used in DEFAULT field attribute must be wrapped into the parenthesis:
ALTER TABLE products ADD openTime1 TIME DEFAULT (TIME(now()));
db<>fiddle here

Issue with MySQL Generated Columns

Hello I am trying to make a alter an exsisting table to add a Generated columns which is the count of all the rows in another table(It will be a like system so I am going to do all the matching and "WHERE" once I get this to work)
I am currently using this.
ALTER TABLE board ADD like_cnt INT GENERATED ALWAYS AS (COUNT(*) FROM likes) NOT NULL;
But it gives me this error
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 'FROM likes) NOT NULL' at line 1
I am using WAMP and it has SQL version 5.7.24
Is this not possible or am I doing something wrong ?
There are limits in GENERATED COLUMNS notably 'Subqueries are not permitted'

Getting an MySQL syntax error and don't know why

Im trying to copy the data from the title and content columns in my articles table from a database into the wp_title and wp_content columns from the wp_posts column from a different database by using this command.
INSERT INTO wp_seetheuniverse.dbo.wp_posts ('wp_title', 'wp_content')
SELECT 'title', 'content' FROM seetheuniverse.dbo.articles;
and this is the error I am getting and do not know why.
ERROR 1064 (42000): 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 '.wp_posts ('wp_title', 'wp_content') SELECT
'title', 'content' FROM seetheuniver' at line 1
INSERT INTO wp_seetheuniverse.dbo.wp_posts ...
You're using a three-part qualified table name like Microsoft SQL Server.
In Microsoft SQL Server, there's a hierarchy of [database].[schema].[table].
MySQL has one fewer levels to the hierarchy. In MySQL, database and schema are the same thing. The terms are synonyms in MySQL.
I would guess that your database (aka schema) is wp_seetheuniverse. That looks like a wordpress database (schema). The dbo schema is a customary schema name in Microsoft SQL Server, not in MySQL.
To confirm, try this statement in the MySQL client:
SHOW DATABASES;
I expect you can get your code to work if you
INSERT INTO wp_seetheuniverse.wp_posts ...
And similarly change other table references so they are [database].[table].
Use below query:
INSERT INTO dbo.wp_posts (wp_title,wp_content)
SELECT title,content FROM dbo.articles;
Where dbo is database name and wp_posts and articles are tables.

MySQL syntax issue on database and table

What is wrong with my syntax?
I'm trying to update several databases in one shot:
update `db_name1`.`db_table` SET `cc_number_enc` = NULL
update `db_name2`.`db_table` SET `cc_number_enc` = NULL
update `db_name3`.`db_table` SET `cc_number_enc` = NULL
and I'm getting query syntax error in phpmyadmin
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 'cc_number_enc = NULL' at line 1
UPDATE
I've rewritten the same query simply by copying & pasting, and now getting the following:
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 'cc_number_enc = NULL' at line 1
Question, is it matter from which database I'm running the query from in phpmyadmin?
try puting semicolon after query. It can happen because of multiple reasons.
references http://www.inmotionhosting.com/support/website/database-troubleshooting/error-1064
MySQl Error #1064
MySQL Nested Queries with Joins
Looks like when copying, your backticks are changed to some other symbol, which looks like backtick, but actually, it is not.
Try again without quotes, or manually put backticks in place.

SQL View from another table

I am trying to create a VIEW from one databse to another, they are both on the same SQL server.
CREATE VIEW mdl_role_assignments
AS
SELECT *
FROM the-db.mdl_role_assignments
Any ideas as to why i cant get this working.
I think its the hyphen in 'the-db', but i need to use this the db is already used.
(Was named by someone else, i would use underscore)
ERROR:
#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 '-db.mdl_role_assignments' at line 4
You could try square brackets to reference complicated names in SQL e.g.
CREATE VIEW mdl_role_assignments
AS
SELECT *
FROM [the-db].mdl_role_assignments;
or backticks
CREATE VIEW mdl_role_assignments
AS
SELECT *
FROM `the-db`.`mdl_role_assignments`;