SQL - How to take a data from a table and insert another preset?

Asked

Viewed 24 times

0

I have a website and need to create a code to send badges, my problem GRAAANDE is, SQL is giving error The idea is to insert in the table "usuarios_placas" the username and the emblem code (code_placa). The code has to take all users of the user table in the username column and enter the badge code in the code_board column.

In short, the site will have a page only with a text box to put the code and the send button, the sending system is all right, I just need the command. It has to take ALL username from the user table and add them TOGETHER with the code assuming it is $badge in the user table What makes the most sense to me is

INSERT INTO `usuarios_placas`(`username`)
SELECT username
FROM usuarios

So far I think that’s right, the question is where in this SQL I add the value of $emblem ? (Use $badge as any value, manage to send a value to it I can, the problem is to insert, it would not enter as $badge, enter as for example: Lvl1 badge)

1 answer

1


If I understand your doubt:

INSERT INTO `usuarios_placas`(`username`, `code_placa`)
SELECT username, 'sua string do emblema'
FROM usuarios

Browser other questions tagged

You are not signed in. Login or sign up in order to post.