I have this command:
INSERT INTO table2 (username,profile) SELECT DISTINCT username,profile
FROM table1 WHERE profile='$profile' and username <> '$sender'
My problem is I want this: INSERT INTO table2 (username,profile,type) where type is gonna be the same string, say “string”
Important: I only want username to be DISTINCT. profile and type can be the same.
Also, profile will always be the same value.
How can I achieve that?
Thanks a lot, regards
Please please please be absolutely certain that
$profileand$senderhave been cleaned of possible SQL injection attacks (if that means nothing to you, go read about Bobby Tables). You’d be far better off using prepared statements, into which you pass your variables as parameters that do not get evaluated for SQL.