Jump to content


Photo

*SOLVED* Are all my querys correct please.


  • Please log in to reply
4 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 April 2006 - 01:49 PM

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

$query="insert into a (name,age)('$name','$age')";


//Query database

$query="select * form a";

// Update database

$query="update a set name='$name' where name='$name'";

//Delete database

$query="delete from a where name='$name'";

// Drop a table

$query="drop table a";

//Drop database

$query="drop database a";

//Drop database
$query="alter table a drop'";

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 12 April 2006 - 02:17 PM

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] INTO a (name,age) VALUES ('$name','$age');
[!--sql2--][/div][!--sql3--]

SELECT:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * FROM a; [!--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
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 April 2006 - 02:32 PM

Thank you for your support obsidian.

Can you kindly exsplain what the * does in a select query cheers other wise solved.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 12 April 2006 - 02:35 PM

[!--quoteo(post=364042:date=Apr 12 2006, 10:32 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Apr 12 2006, 10:32 AM) View Post[/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 FROM a; [!--sql2--][/div][!--sql3--]
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 April 2006 - 02:40 PM

[!--quoteo(post=364045:date=Apr 12 2006, 02:35 PM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Apr 12 2006, 02:35 PM) View Post[/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 FROM a; [!--sql2--][/div][!--sql3--]
[/quote]

Thank you agin.

[!--sizeo:4--][span style=\"font-size:14pt;line-height:100%\"][!--/sizeo--]solved[!--sizec--][/span][!--/sizec--]
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users