mysql

using mysqli to extract custom data

I am using a function in php for all select queries so that i can dynamically retrieve data from my database ..... I just wanted to know that is my code secure and efficient or if their is a better way to do this, if so please point me to the right direction...thanks class mysql { private $conn; function __construct(){ $this->co...

MySQL Range and Average

I'm wondering if in MySQL you are able to find a range within values along with the average in a query. Assume the table below please: ----------------------------------------- | ID | VALUE | ----------------------------------------- | 1 | 30 | -----------------------------------...

Single Equals in MYSQL

Hi, I was wondering why MYSQL uses a single equals sign in conditional statements instead of the more typical two equals signs. Is there a technical/historical reason for this? Thanks. ...

SQL query for Calculating Total No. of Orders per Day?

Hello Can anyone post a SQL query for Calculating Total No. of Orders per Day? Here are the Columns along with their data in my Database. order_id order_placed_date order_total - 1 12/30/2008 12:06:24 AM 2499.99 - 2 2/3/2009 1:57:17 AM 199.99 - 3 2/3/2009 1:58:27 AM 449.99 - 4 5/3/2009 1:58:48 AM 299.99 ...

PHP and mysql question

hello everyone i'm having some problem ... question is i want to get the information from a form and save it in database the data is (comment, uploading pictures and email) when i did it it gave a warning the code // move file from temp location on server to your uploads folder move_uploaded_file($F1["tmp_name"], "Uploads/$F1[name]"...

Problem in using UPDATE command in PHP.

I am have some problem in updating my qotwVote1a table's Vote1a field through PHP. Could you please have a look at the code, and tell me what am i doing wrong in here. $result = mysql_query("SELECT * FROM qotwVote1a WHERE QuestionId='".$questionId."' AND MemberId='".$id."'"); while($row = mysql_fetch_array($result)) { $or...

How to install latest lighttpd PHP (fastcgi) and MySQL on centOS 5.3

yum always install old version but i want to install latest versions. Thanks. ...

Any good tools to migrate from MySQL to SQLite3?

I'm struggling to find a good tool to help me migrate a MySQL database to SQLite. I've seen a couple of different Perl scripts (including one discovered here), but they do not appear to work correctly for me. ...

Can anyone help me with the PHP Chart ?

I am trying to display Total Order Amount Per Day in the Present Month. $sql = "SELECT date(order_placed_date), COUNT(order_id), SUM(order_total) AS order_total FROM orders WHERE order_placed_date>=date_sub(current_date, INTERVAL 31 DAY) GROUP BY date(order_placed_date)"; if (!...

MySQL Query: Displaying counts for many groups with many records

I need to produce a large HTML table with quarterly counts for several (around 50) different groups (jurisdictions). I have a MySQL table with around 16,000 rows which have 'jurisdiction_id' and 'quarter' fields. Unfortunately my client doesn't want the resulting report to be paginated. How would I construct a good MySQL query from which...

can you begin a mysql statement with "IF"?

I am trying to implement "IF record EXISTS THEN UPDATE ELSE INSERT" in mysql. Specifically, I have to figure out how to do that with Doctrine ORM. One solution using native MySql is to use "ON DUPLICATE KEY UPDATE". This is unfortunately not supported in Doctrine. Another semi solution is to use "REPLACE INTO" syntax. Doctrine sup...

How to keep Mysql high availability while column datatype & value are changed?

Hi, I am looking for a strategy to keep mysql and web service high availability while changing column datatype and value. The scenario is: for example, a student table has columns student id(Integer), student name (vachar) and rank percentage (Integer). The integer value in rank percentage is the percentage integer number, for example,...

How do I access another MySQL Database from another IP Address with PHP?

Ok, If you can answer this question, you deserve the nobel peace prize. Anyways, here's the situation. I'm using Slicehost dot net, and I have 2 slices (two different IPs). One slice is my mail server and the other is my normal website. I'm running Ubuntu (8.04 or 8.10, something like that, it shouldn't matter). What I'm trying to do is...

Does MySQL's ALTER TABLE ADD PRIMARY KEY also cluster the data?

Does MySQL's ALTER TABLE ADD PRIMARY KEY also cluster the data, or do I need to create the table from scratch with the primary key to get the clustering? ...

MySql Geospatial bug..?

This question is for Mysql geospatial-extension experts. The following query doesn't the result that I'm expecting: create database test_db; use test_db; create table test_table (g polygon not null); insert into test_table (g) values (geomfromtext('Polygon((0 5,5 10,7 8,2 3,0 5))')); insert into test_table (g) values (geomfromtext('...

MySQL Views: Sub-Joins

I am wanting to have a view table that aggregates rows from four tables. The first primary table is client and is just a primary key unique id and a profile_id. The second table, profile, holds all of the firstname, address, zipcode kind of information. The third table is email; there can be many email objects to one client object but t...

How to get a list of mysql user accounts

Version 5.4.1 Am using command line utility and can navigate through database but now need to see the list of user accounts. Cheers ...

connecting Python 2.6.1 with MySQLdb

Hi All I am using Python 2.6.1 and I want to connect to MySQLdb, I installed mySQL in my system, and I am trying to connect MySQL-python-1.2.2.win32-py2.6 from http://www.codegood.com/archives/4 site but its not working while running my application its saying that No module named MySQLdb please any one provide me the proper setu...

MySQL select "accumulated" column

I'm not sure what to call this besides an "accumulated" column. I have a MySQL table with a column that looks like +---+ |val| +---+ | 1 | | 4 | | 6 | | 3 | | 2 | | 5 | +---+ I want to do a query so that I get this column along with another column which is the sum of all the rows from this column so far. In other words, the select wo...

Printing the Categories and Sub Categories Alone

function build_list($id=0,$collapsed="") //return an array with the categories ordered by position { $RootPos = ""; $this->c_list = array(); if($id != 0){ $this_category = $this->fetch($id); $positions = explode(">",$this_category['position']); $RootPos = $positions[0]; } // lets fetch the root categories $sql = "SELECT *...