Jump to content

*SOLVED* Are all my querys correct please.


redarrow

Recommended Posts

Hope you can help i am trying to learn all the most used querys are these query below right if not can you tell me how to do them properly thank you.

These mysl database querys has to be learnt before i can proceed on my course thank you.


// Insert database

[code]
$query="insert into a (name,age)('$name','$age')";
[/code]


//Query database

[code]
$query="select * form a";
[/code]

// Update database

[code]
$query="update a set name='$name' where name='$name'";
[/code]

//Delete database

[code]
$query="delete from a where name='$name'";
[/code]

// Drop a table

[code]
$query="drop table a";
[/code]

//Drop database

[code]
$query="drop database a";
[/code]

//Drop database
[code]
$query="alter table a drop'";
[/code]
Link to comment
https://forums.phpfreaks.com/topic/7204-solved-are-all-my-querys-correct-please/
Share on other sites

i think you've got them for the most part, but you've got a couple misspellings and missing words ;-)

INSERT:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']INSERT[/span] [color=green]INTO[/color] [color=orange]a[/color] (name,age) VALUES ([color=red]'$name'[/color],[color=red]'$age'[/color]);
[!--sql2--][/div][!--sql3--]

SELECT:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * [color=green]FROM[/color] [color=orange]a;[/color] [!--sql2--][/div][!--sql3--]

also, your alter table is right syntax, but it does not allow you to drop the table:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']ALTER TABLE[/span] a [span style=\'color:blue;font-weight:bold\']DROP[/span] COLUMN col_1;
[!--sql2--][/div][!--sql3--]

hope this helps
[!--quoteo(post=364042:date=Apr 12 2006, 10:32 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Apr 12 2006, 10:32 AM) [snapback]364042[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Thank you for your support obsidian.

Can you kindly exsplain what the * does in a select query cheers other wise solved.
[/quote]

sure. the "*" simply says to select ALL COLUMN from the rows that match the query. the alternative would be to define which columns you want to pull only:

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] col_1, col_2, col_3 [color=green]FROM[/color] [color=orange]a;[/color] [!--sql2--][/div][!--sql3--]
[!--quoteo(post=364045:date=Apr 12 2006, 02:35 PM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Apr 12 2006, 02:35 PM) [snapback]364045[/snapback][/div][div class=\'quotemain\'][!--quotec--]
sure. the "*" simply says to select ALL COLUMN from the rows that match the query. the alternative would be to define which columns you want to pull only:

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] col_1, col_2, col_3 [color=green]FROM[/color] [color=orange]a;[/color] [!--sql2--][/div][!--sql3--]
[/quote]

Thank you agin.

[!--sizeo:4--][span style=\"font-size:14pt;line-height:100%\"][!--/sizeo--]solved[!--sizec--][/span][!--/sizec--]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.