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
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
Link to comment
Share on other sites

[!--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--]
Link to comment
Share on other sites

[!--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--]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.