mysql

How to count NULL values in MySQL?

I want to know how can i find all the values that are NULL in the MySQL database for example I'm trying to display all the users who don't have an average yet. Here is the MySQL code. SELECT COUNT(average) as num FROM users WHERE user_id = '$user_id' AND average IS_NULL ...

Mysql ADDDATE() or DATE_ADD() with table columns?

How do I do something like the following SELECT ADDDATE(t_invoice.last_bill_date, INTERVAL t_invoice.interval t_invoice.interval_unit) FROM t_invoice ...where the column t_invoice.last_bill_date is a date, t_invoice.interval is an integer and t_invoice.interval_unit is a string. What I like about the ADDDATE() function is that if ...

One table, need multiple values from different rows/tuples

I have tables like: 'profile_values' userID | fid | value -------+---------+------- 1 | 3 | [email protected] 1 | 45 | 203-234-2345 3 | 3 | [email protected] 1 | 45 | 123-456-7890 And: 'users' userID | name -------+------- 1 | joe 2 | jane 3 | jake I want...

Best practices for querying an entire row in a database table? (MySQL / CodeIgniter)

Sorry for the novice question! I have a table called cities in which I have fields called id, name, xpos, ypos. I'm trying to use the data from each row to set a div's position and name. What I'm wondering is what's the best practice for dynamically querying an unknown amount of rows (I don't know how many cities there might be, I wan...

Next and Previous MySQL row based on name

Hi everyone, I have a table with details on personnel. I would like to create a Next/Previous link based on the individual's last name. Since personnel were not added in alphabetical order, selecting the next or previous row based on its ID does not work. It is a hefty table - the pertinent fields are id, name_l, and name_f. I would li...

Conditional Batch file renaming with mysql data

Hello, I wonder if anyone knows how could I rename multiple files, all of them originally named with same structure, and add some data extracted from a mysql DB according to specifics rules. For example I have 500 files named with this vars: ID NAME ADDRESS PHONE.wav => 1234567 PAULSIMON WESTDR122 9942213456.wav Now I need to rename ...

Why is this PHP loop rendering every row twice?

I'm working on a real frankensite here not of my own design. There's a rudimentary CMS and one of the pages shows customer records from a MySQL DB. For some reason, it has no probs picking up the data from the DB - there's no duplicate records - but it renders each row twice. <?php $limit = 500; $area = 'customers_list'; $prc = 'custom...

mysql left outer join

I have two tables: employee with fields employee_id, firstname, middlename, lastname timecard with fields employee_id,time-in,time-out,tc_date_transaction I want to select all employee records which have the same employee_id with timecard and date is equal with the current date. If there are no records equal with the current date th...

How to Practically Split Values from CSV File into MySQL Database

Let's suppose I have the following line in a CSV file (I removed the header row in this example): "500,000",2,50,2,90000 I have a PHP script read the CSV file, break the file into individual lines, and store each line in an array called $linearray. Then, I use a foreach loop to look at each line individually. Within the foreach loop,...

if else query in mysql

i need an example of nested if-else condition in mysql query ...

Organize array in PHP from mysql

Hi i have a social networking website. what i want it to do is pull out my friends status updates. basically what it does is i have a mysql query that pulls out all of my friends and in that while loop there is another mysql query that pulls out the status's from my friends. i want it to be in order of date but since its one while loo...

Mysql - return last 3 results in table

Hi, i was wondering if there was an easy way with just an sql statement to return the last three results in the table but in that order i.e. if there are a hundered results it would return in the order of 98, 99, 100 not simply ordering by id DESC and limit 3 which would return in order 100, 99, 98 Any help much appreciated. p.s. in th...

How to remove my corrupted mysql from wamp and connect separatly installed mysql to wamp?

How to remove my corrupted mysql from wamp and connect separatly installed mysql to wamp? If any body know please help me. ...

MySQL - NULL value check and Dynamic SQL inside stored procedure

DROP PROCEDURE IF EXISTS HaveSomeFun; CREATE PROCEDURE HaveSomeFun(user_id CHAR(50),house_id CHAR(50),room_id CHAR(50),fun_text TEXT,video_url CHAR(100)) BEGIN DECLARE query_full TEXT; SET @fields_part = 'INSERT INTO fun(FunKey,UserKey,FunBody,LastModified'; SET @values_part = CONCAT(') VALUES( NewBinKey(), KeyToBin(\"', user_id, '\")...

Implementing Tagging System with PHP and mySQL. Caching help!!!

With reference to this post: http://stackoverflow.com/questions/2122546/how-to-implement-tag-counting I have implemented the suggested 3 table tagging system completely. To count the number of Articles per tag, i am using another column named tagArticleCount in the tag definition table. (other columns are tagId, tagText, tagUrl, tagArti...

NHibernate, MySQL, InnoDB and nested transactions

I'm using NHibernate to access an MySQL database using InnoDB tables. I know InnoDB doesn't support nested transactions, but I keep thinking things would have been much simpler if it did. Take a look at this method for instance.. SessionManager opens a new session per thread. If I didn't store the transaction, it previous would have bee...

mysql - offset problem

Hi, I recently posted a question about getting last 3 results in table in the correct order. I now want the get all comments apart from the last 3 in the correct order. Here is my syntax; SELECT * FROM (SELECT * FROM $table ORDER BY ID DESC OFFSET 3) AS T ORDER BY TIME_STAMP The error I am receiving is: You ...

Difference between MySQL IS NOT NULL and != ''

Is there any difference between MySQL IF (myText IS NOT NULL) THEN and IF (myText != '') THEN ...

type casting in mysql

i have passportno(varchar) in database. i am entering values like this 001,002,003. and i want to display like sorting order. now i wrote query like this "select * from passport_registration where status=1 ORDER BY passportno" then displaying output like this......077,088,099,100,1000,1001,1009,101,1010 i want to diplay sort order. ...

How I can set a column value for all my rows that already exist in the database with some sort of mysql statement

I want to set the value of the column 'character_hold' to 'no' for all my rows in my MYSQL database. Is there a SQL statement I can use in phpmyadmin to set them all to 'no'? ...