WEBVTT 00:00:07.230 --> 00:00:14.370 In this video we're going to learn how to delete data from a database using PSP and my as well. 00:00:14.370 --> 00:00:26.190 So let's impose the content from our previous file gate and change the title to delete data and also 00:00:26.190 --> 00:00:34.440 change the heading to delete data. 00:00:34.440 --> 00:00:38.680 So first of all we're going to connect to the database as we've done before. 00:00:39.030 --> 00:00:43.250 And then we are going to delete some data. 00:00:43.380 --> 00:00:47.430 So the only thing that's going to change here is the Escurial 00:00:50.280 --> 00:00:51.020 query. 00:00:51.410 --> 00:00:52.790 OK. 00:00:54.030 --> 00:00:58.710 And everything else is going say the same which is going to change the paragraph too. 00:00:58.740 --> 00:01:03.150 So the success paragraph so data was deleted successfully. 00:01:03.360 --> 00:01:04.530 OK. 00:01:05.440 --> 00:01:11.010 And it's. 00:01:11.880 --> 00:01:23.370 So for example is trying to delete all the records where the the first name is George. 00:01:23.370 --> 00:01:24.070 OK. 00:01:24.580 --> 00:01:29.810 So so are we going to use the keyword delete. 00:01:30.880 --> 00:01:31.390 OK. 00:01:31.650 --> 00:01:35.420 So from a user's table name. 00:01:35.810 --> 00:01:36.110 OK. 00:01:36.120 --> 00:01:40.050 And the condition is where first name 00:01:43.700 --> 00:01:44.270 equals 00:01:47.270 --> 00:01:48.020 George. 00:01:48.210 --> 00:01:51.320 So the value goes in single quotes. 00:01:51.950 --> 00:01:52.640 OK. 00:01:53.010 --> 00:02:04.740 So if we save and refresh our page and it says this was treated successfully. 00:02:04.890 --> 00:02:13.170 So let's refresh our results page and make sure that we don't have this row anymore. 00:02:13.370 --> 00:02:15.410 OK. 00:02:15.480 --> 00:02:18.350 And you can see those last row has been deleted. 00:02:18.990 --> 00:02:21.050 OK. 00:02:23.190 --> 00:02:25.300 OK. 00:02:26.910 --> 00:02:31.940 If we want to drop the whole table we can write another query. 00:02:32.730 --> 00:02:36.390 So the query is going to be 00:02:41.370 --> 00:02:46.410 drop followed by the name of the table. 00:02:46.770 --> 00:02:50.240 And if you execute this the whole table is going to be dropped. 00:02:50.310 --> 00:02:51.940 Ok so I'm going to try that. 00:02:52.180 --> 00:02:54.140 They can try it. 00:02:54.750 --> 00:03:01.610 If you do this the table is going to disappear OK. 00:03:01.870 --> 00:03:04.980 And it is one more thing before we finish. 00:03:05.020 --> 00:03:09.240 Normally when we open a connection 00:03:12.270 --> 00:03:20.780 once the script has been executed fully then the connection is going to be closed by itself. 00:03:20.790 --> 00:03:21.200 OK. 00:03:21.270 --> 00:03:24.680 So you just close automatically. 00:03:25.920 --> 00:03:31.890 But if you want to close the connection in a specific location in the scripts then there is a function 00:03:31.890 --> 00:03:32.560 for that. 00:03:32.760 --> 00:03:33.810 OK. 00:03:33.860 --> 00:03:44.920 So so it's a close connection we can use the procedural way we asked really underscore close. 00:03:45.100 --> 00:03:45.640 OK. 00:03:45.810 --> 00:03:50.630 Followed by the connection variable which is link in our case. 00:03:50.730 --> 00:03:54.460 Otherwise you can use the object oriented way. 00:03:54.840 --> 00:03:59.520 So by accessing inside the link variable the method. 00:03:59.520 --> 00:04:00.530 Close. 00:04:00.920 --> 00:04:02.650 OK. 00:04:02.700 --> 00:04:11.500 And you give it as an argument the same link variable. 00:04:14.440 --> 00:04:14.760 OK. 00:04:14.760 --> 00:04:23.870 So let's Common's one of these and save. 00:04:29.920 --> 00:04:30.090 OK 00:04:30.480 --> 00:04:35.540 .