how do i search an SQL database for an Id, and if i find that ID, delete that entire row?
>>51731685
select
*
from
table
where
id
=
###
delete is left as an exercise for the reader
>>51731685
DELETE FROM table_name
WHERE ID = id_value
?
delete from table where id = ?
DELETE FROM `table` WHERE `id`=`query`
>>51731685
WHEN
FIND
Id
LOOK
AT
MATCHEY
MATCHEY
THEN
DELETE
ROW
>>51731714
>>51731708
>>51731702String selectSQL = "select r from ReservationDrop r where r.id like :id";
try {
Query selectQuery = entityManager.createQuery(selectSQL);
would work, how would i know if a row was deleted so i can confirm the deletion?
>>51731685
DROP DATABASE yourdbname
You'd learn more if you did your own homework, rajeesh.
>>51731745
i think netbeans doesnt allow this in default
>>51731742
Check the size of the table before and after. If it has decreased by one, it is successful.
There's probably a more elegant way of doing it, but it works.
YOU FORGOT THE COMMIT
-1000 points
faggots
>>51731685
are you a retard? why the fuck even make a thread when bing could've got you the answer in seconds?
>>51731783
He wanted the 4chan experience
>>51731755
there was no mention of ide or even sql dialect. it would work on mssql and everyone knows that this is the only logical choice for actual business databases.
>>51731742
Add
OUTPUT deleted.*
somewhere in there
ANSI SQL faglords why would you use vendor specific code to delete a row
>>51731822
what should i use?
>>51731685function DeleteRowFromDatabaseThatMatchesID(int Id)
{
DatabaseConnector conn(DB_ID, DB_USER, DB_PASSWORD);
if (!conn.connect())
return false;
DatabaseSelector select(conn);
select.find("ID", "EQU", Id);
if (!select.found())
return false;
DatabaseDeleter delete(selector);
if (!delete.delete())
return false;
return true;
}
Easy peasy.
>>51732117
>let's do two operations when one will suffice
confirmed for not knowing the first thing about databases
Just delete it. Why the hell do you need to search it first?
>>51731790
>He wanted the 4chan experience
moot should of branded this to make more shekels
>inb4 should of
>>51731685
anon, we know this is your homework... please try to do it by yourself or else you will never learn about SQL
>>51731685
delete from table_name where ID = (select id from table_name where Id = ?)
>>51736587
>select id where id =
TRUNCATE TABLE dbo.table
Speaking of which, why does beautifying code in mysql make it look so much shittier? No I don't want a simple command to take up 6 lines.
>>51737330
>he doesn't know what sub-queries are