Click here to Skip to main content
14,640,935 members
Rate this:
Please Sign up or sign in to vote.
See more:
This has me perplexed and doesn't help that I'm having to use phpMyAdmin.

INSERT	INTO aqua_clients
VALUES	(SELECT meta_value FROM _YYV_frmt_form_entry_meta WHERE meta_key = 'name-4')

Error is:
#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 'SELECT `meta_value` FROM _YYV_frmt_form_entry_meta WHERE `meta_key` = 'name-4')' at line 3

What I have tried:

Googling and rewriting, but am not getting any progress. The main table has the values in one column (Meta_Value), and the field name sits in Meta_key.

I'm trying to create a After Insert that places the values in their corresponding columns as soon as they are submitted via a Wordpress form.
Updated 12-Jul-20 9:47am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

When you are using a SELECT to populate the values, you "skip" the VALUES syntax
MySQL :: MySQL 8.0 Reference Manual :: INSERT ... SELECT Statement[^]
INSERT INTO aqua_clients (parent_firstname)
SELECT  meta_value
FROM    _YYV_frmt_form_entry_meta
WHERE   meta_key = 'name-4'
Maciej Los 13-Jul-20 5:05am
MadMyche 14-Jul-20 21:17pm
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100