Starting with a single table (user_import) brought in from .csv
| Name | Login | Email | CustomA | CustomB |
+------------+-------+----------------------+---------+---------+
| John Smith | johns | john_smith@gmail.com | Blarg | Narx |
| Max Power | maxp | max_power@gmail.com | Jarg | Lipdo |
+------------+-------+----------------------+---------+---------+
Attempting to have it populate a Joomla! users table
| id | name | username | email | ...
| 514 | Super User | admin | admin@gmail.com | ...
| 515 | John Smith | johns | john_smith@gmail.com | ...
| 516 | Max Power | maxp | max_power@gmail.com | ...
and insert any custom custom fields to the user_profiles table
+---------+-------------------------------------+---------------+----------+
| user_id | profile_key | profile_value | ordering |
+---------+-------------------------------------+---------------+----------+
| 515 | customprofile.custom_a | "Blarg" | 1 |
| 515 | customprofile.custom_b | "Jarg" | 2 |
| 516 | customprofile.custom_a | "Narx" | 1 |
| 516 | customprofile.custom_b | "Lipdo" | 2 |
+---------+-------------------------------------+---------------+----------+
I don't think there is a way to do this in a single call as the user_id has to auto_increment
First query is pretty strait forward
INSERT INTO prknc_users (name, username, email, params, password)
SELECT Name, Login, Email, '{}', 'tuChaSw-tEte72_!eSW#muc3@trew8steZacra2e7a7R6yuqAyeSAXUy=Stu'
FROM user_import;`
The second one is the one I need some help with, tried with this for one:
INSERT INTO user_profiles (user_id, profile_key, profile_value, ordering)
SELECT (SELECT users.id FROM users, user_import WHERE users.email = user_import.Email), 'customprofile.custom_a',user_import.CustomA, '1'
FROM user_import;
Failing hard. Please help me out if you can.