[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 686
  • Last Modified:

truncate data then insert mysql through cpanel

I am running the code below for a php mysql web site and all i need to do is to delete the existing rows then update them with the new data that it but cannot seem to get the syntax correct for the truncate table 'jos_students' then the INSERT i will be running this from phpadmin on my web page.
any help with the syntax would be handy thanks in advance.
truncate table 'jos_students'
INSERT INTO `cambridg_cambridge2`.`jos_students` ( `StudentID` ,`AusAddress` ,`AustSuburb` ,`PostCode` ,`Phone` ,`Mobile` ,`Email` ,`IELTSScore` ,`Country` 
 
,`OverseasAddresss` ,`levelp` ,`callbase` ,`DelOrUpdate`)VALUES
("10070","75 kensington rd","summer hill         ","2130","-","0433718555","rossiniz48@hotmail.com","_","China","-","-",0,0);

Open in new window

0
sydneyguy
Asked:
sydneyguy
  • 3
  • 2
4 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
for strings, use single quotes (') and not double quotes (") in MySQL
also, you need to run the 2 statements apart, and not together, or have a ";" between them
0
 
mahomeCommented:
What is your error message?

What I see is that the truncate don't have the database specification. So it should be

truncate table `cambridg_cambridge2`.'jos_students'

Open in new window

0
 
sydneyguyAuthor Commented:
now the truncate works fine by its self
and the insert works fine by its self but together no go the way they are
tried the , as well as ; between the statements but still no go


SQL query:

TRUNCATE TABLE 'jos_students',
INSERT INTO `cambridg_cambridge2`.`jos_students` (
`StudentID` ,
`AusAddress` ,
`AustSuburb` ,
`PostCode` ,
`Phone` ,
`Mobile` ,
`Email` ,
`IELTSScore` ,
`Country` ,
`OverseasAddresss` ,
`levelp` ,
`callbase` ,
`DelOrUpdate`
)
VALUES (
"10070", "75 kensington rd", "summer hill ", "2130", "-", "0433718555", "rossiniz48@hotmail.com", "_", "China", "-", "-", 0, 0
)

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''jos_students',
INSERT INTO `cambridg_cambridge2`.`jos_students` ( `StudentID` ' at line 1
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
then, I fear that cpanel does not allow to run several statements at once...
0
 
sydneyguyAuthor Commented:
TRUNCATE TABLE `cambridg_cambridge2`. 'jos_students'
does not run at all

SQL query:

TRUNCATE TABLE `cambridg_cambridge2`. 'jos_students'

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''jos_students'' at line 1
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
that's the single quotes are wrong, it must be backticks (`)

TRUNCATE TABLE `cambridg_cambridge2`. `jos_students`

but that is something you know, and which I think was only a typo...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now