mercredi 13 juillet 2016

How to alter drop all columns that start with a specific string using SQL

I have 1 table with all of my user information. All information is the form of $user.name, $user.date, etc, ($user = username)

I want the user to be able to delete their account and alter the table to drop all of the columns that starts with the string of the user.

How would I do this... right now I am doing it the long way, which is still not working either.

            $sql = "ALTER TABLE userDatabase
        DROP COLUMN `$user.hour`,
        DROP COLUMN `$user.plannerData`,
        DROP COLUMN `$user.eventName`,
        DROP COLUMN `$user.eventStart`,
        DROP COLUMN `$user.eventEnd`,
        DROP COLUMN `$user.eventFreq`,
        DROP COLUMN `$user.eventSlide`";

Aucun commentaire:

Enregistrer un commentaire