OpenCart – Using SQL Console in cPanel

This nifty article will teach you how to use the SQL panel in cPanel. Every now and then you will have need to run SQL commands directly onto the DB rather than using your server side scripting language and the web. cPanel makes it very easy to do this. If you are used to writing SQL Procedures in PHP, for example, you will come to notice very quickly that it is very similar. Raw SQL syntax is a little different but you will catch on very quick. First, open up your cPanel. Sometimes, depending upon what type of account you have there could be TWO way’s to login to your cPanel with Arvixe. Make sure that you choose the HTTPS (SEURE METHOD). Once in cPanel go to your PHP MY ADMIN. srreen1.fw

Now once in your phpMyAdmin you need to open up one of your Databases. Clearly, you should have already set up a DB. If not, go to MySQL DATABASES and set one up. There are plenty of other tutorials for this :). Now, once in php and having selected a database, click on the SQL TAB SQL.fw

Let’s set up a little example of an UPDATE QUERY. Say you wish to UPDATE a field in the ADDRESS TABLE.

Disclaimer: DO NOT ATTEMPT TO RUN THESE TESTS ON A LIVE WEBSITE. IF YOU ARE THEN MAKE A BACK UP FIRST.

UPDATE QUERY

When opening the SQL TAB you will see a text input area. Here is where you will insert your syntax. Place the following syntax:

UPDATE `dbprefix_customer` SET firstname = 'joseph' WHERE customer_id ='some number';

In the above code you are updating the customer with the customer ID of _____. If you do not specify a WHERE CLAUSE then it will update every single first name to ‘joseph’. This would normally not be a desirable result so it is always recommended using WHERE or WHERE/AND when doing updates.

SELECT QUERY

SELECT * FROM `dbprefix_customer` WHERE firstname <> 'joseph' ORDER BY customer_id DESC;

So here we are selecting all rows in the customer table where the customer’s names are not joseph and showing results by customer ID and DESCENDING.

The SQL console is very powerful in fact you can design your entire DB in it if you know syntax well enough. My next tutorial will be on something similar but using the Opencart framework to run SQL QUERIES instead with PHP.

Looking for quality OpenCart Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , , , | Posted under OpenCart | RSS 2.0

Author Spotlight

Joe Stenhouse

Joe Stenhouse

I am a web application developer that specializes in PHP, JAVASCRIPT, MYSQL, HTML, and CSS. We manifest exciting potentials within the world wide web through means of innovation.

One Comment on OpenCart – Using SQL Console in cPanel

  1. Vijaya says:

    Thanks for the article. A quick question, can you run a sql script with multiple sqls? For eg, if I want to run 10 update commands, can I do that at one shot or do I have to type in each command and run them separately?

Leave a Reply

Your email address will not be published. Required fields are marked *


6 − = 1

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>