mysql

Codeigniter SQL query

Hi there I am trying to do a COUNT that has WHERE clauses in it, the code I am using is function count_tasks($userId) { $this->db->count_all('tasks'); $this->db->where('tasksAssignedTo', $userId); $query = $this->db->where('taskPriority_taskPriorityId !=', 6); return $query; However Codeigniter only seems to be running the foll...

mysql & php - query for record with all or fewer values, but not more

(SOLVED, SEE END) I need hints on the PHP or MySQL code structure for the following: Let's say you have X unique boxes, and Y types of fruit. Each box can contain one of each type of fruit. Some boxes might have only 2 types, some might have every type. All boxes have at least one type. For the query, the user has a list of checkboxe...

MySQL displaying wrong time for some timezones.

I am using MySQL 5.1.34 community server. I have taken the MySQL timezone description tables from here. Now for some timezones the time displayed by MySQL is wrong, because of wrong "day light saving" calculation for these time zones. Ex: The query select convert_tz(now(),'GMT','Australia/Sydney'); is giving wrong result. Wrong t...

mysql load testing tools

Hi All, I want to calculate the each row size of a table. are there any tools available for this. Also Does anyone aware of any load testing tools. Thanks in advance. Regards, Manasi ...

Is it possible to save a word file in MYSQL database and to view the content "AS IT LOOKS" in the Browser.

Hi all, For example, i am uploading a word file with some FORMATTED contents in the database. The content in the word document is aligned. I done up to the above level . My issue is how can i able to view the CONTENTS AS IT LOOKS EXACTLY (means the exact formatted contents) IN A BROWSER. Kindly help me out of this issue. Thanks in Ad...

MySql and PHP Question?

I was wondering if i had a mysql field named names that had many names in the same field that a user can pull from it how should my field be setup? For example if the user entered about 20 names into the same name field how should my mysql table be setup if my table is not set up correctly. And how can I display each 20 names from the ...

is my mysql query correct? (does not seem like it)

I want to select data between 1 week ago data until today data: SELECT username, email, date FROM users WHERE date(date) BETWEEN (CURDATE() AND (CURDATE() - 7)) ORDER BY userid DESC LIMIT 10 Hope you guys can help me. It does not work!!! This question has been answered by lexu (can somebody close this question?) ...

Optimizing my mysql statement! - RAND() TOO SLOW

So I have a table with over 80,000 records, this one is called system. I also have another table called follows. I need my statement to randomly select records from the system table, where that id is not already listed within the follows table under the current userid. So here is what I have: SELECT system.id, system.u...

Mysql how many search results

Hi. How can I check how many results is returned from mysql db? Im using this code to fill a table with results from the mysql db: $qry_result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($qry_result)) Im want to display how many search results there was on the users search criteria... Thanks ...

how to limit result based on the fields

How to use ' LIMIT' in mysql database query based on fields . just consider a user has 10 phone number and i would like to get only 5 phone number for that user . I would like to get only 5 phone numbers per user . not only 5 results from database ? ...

"how many search results from mysql" help

Hi... I got some help with gettin the number of rows returned from mysql, and it works fine... BUT, how do I get the number of rows with a certain field value? Do I have to make a new Mysql search query? Here is the code where I query mysql and display in a table using fetch_array... Also, Im using mysql_num_rows to get number of rows....

How to change MySQL column definition?

create table test( locationExpect varchar(120) NOT NULL; ); I want to change it to : create table test( locationExpect varchar(120); ); ...

Optimizing COUNT(*) query with 4 MM relations and larger table

I am struggling (again) with the table from this question: http://stackoverflow.com/questions/1555561/how-to-optimize-this-query-4-mm-tables-involved It is one main table product_table which has four MM relations via the lookup tables mm1 to mm4. The lookup tables have the fields uid_local containing the uid of the product_table and ...

How to eliminate duplicate calculation in SQL ?

I have a SQL that can be simplified to: SELECT * FROM table WHERE LOCATE( column, :keyword ) > 0 ORDER BY LOCATE( column, :keyword ) You can see there is a duplicate of "LOCATE( column, :keyword )". Is there a way to calculate it only once ? ...

MySQL question: Indexes on columns!

Hi guys... I've a MySQL question I've two tables (posts and authors) in a one to many relationship (since each post is written by an author and an author can write multiple posts). So here are the tables: Authors: id:BIGINT, name:VARCHAR(255) Posts: id:BIGINT, author_id:BIGINT, body:TEXT I've got 700,000 posts and 60,000 au...

Graphs from MYSQL to jquery FLOT

Hi friends, I've discovered flot for jquery for drawing nice graphs. But I can't parse the data I want to represent from MYSQL. It's driving me crazy because I get this error: uncaught exception: Invalid dimensions for plot, width = 0, height = 0 Is there any way to put MYSQL data into flot apart from this?: php part: <?php includ...

A question about JOIN.

I need to do something like this to fill a parts table: SELECT (CASE t1.part IS NULL THEN t2.part ELSE t1.part END) AS partno, t3.desc FROM t1 LEFT JOIN join t2 ON [certain condition] LEFT JOIN t3 ON t1.part = t3.part OR t2.part = t3.part ...so this will select the value for partno from t2 in case that part i...

Handling missing columns in MySQL

Working on parsing a bunch of databases put together in an older, more freewheeling time into a new schema. Basically it's one database per year, with database names like foo98, foo99, foo2000, etc. So for the most recent foo data, I can do something like SELECT foo_person.mdname AS middle_name, ... FROM foo_person, foo_place, foo_thin...

Insert into select and update in single query

I have 4 tables: tempTBL, linksTBL and categoryTBL, extra on my tempTBL I have: ID, name, url, cat, isinserted columns on my linksTBL I have: ID, name, alias columns on my categoryTBL I have: cl_id, link_id,cat_id on my extraTBL I have: id, link_id, value How do I do a single query to select from tempTBL all items where isinsrted = 0 ...

Count parents backwords in one SQL Query?

I have a MySQL database (created by Wordpress) and this is similar to what it looks like: ID parentID otherStuff 54 55 this is a test 55 56 another test 56 0 last test What I need to do is to check how deep down a page is. I know that when it reaches parentID 0 it's finished. I could wri...