mysql

MySQL returning an empty field: CONCAT(nonEmpty1,empty2,nonEmpty3) = NULL

I have PHP 5 code accessing a MyISAM table on MySQL 5 server. The query looks like this: SELECT CONCAT(fName1,' ',mName2,' ',lName3) AS userName FROM users WHERE level > 10 When there's no mName filled in, I am expecting output like "fname lname" , but I'm getting "" (empty string) instead (the number of rows returned is co...

How do I subtract using SQL in MYSQL between two date time values and retrieve the result in minutes or second?

I want to subtract between two date time values using SQL in MySQL such that I get the interval in minutes or seconds. Any ideas? I want to run a SQL query that retrieves uses from a database who have logged in like 10 minutes from the time. ...

SQL - adding fields to query to sorty by

I'm working with a third party software package that is on it's own database. We are using it for the user management back bone on our application. We have an API to retrieve data and access info. Due to the nature of information changing daily, we can only use the user_id as a pseudo FK in our application, not storing info like their...

Distinct Help

Alright so I have a table, in this table are two columns with ID's. I want to make one of the columns distinct, and once it is distinct to select all of those from the second column of a certain ID. Originally I tried: select distinct inp_kll_id from kb3_inv_plt where inp_plt_id = 581; However this does the where clause first, and th...

Trac Using Database Authentication

Is it possible to use a database for authentication with Trac? .htpasswd auth is not desired in this install. Using Trac .11 and MySQL as the database. Trac is currently using the database, but provides no authentication. ...

how to enable database auto-reconnect in PHP?

and the database is MYSQL ...

Distinct Popular Hits

Can someone help me with this query: SELECT su.name,su.imdb , su.id, su.owner, COUNT(*) AS count FROM subhits AS h LEFT JOIN subtitles AS su ON h.subid=su.id WHERE su.added BETWEEN '" . $lweek . "' AND '" . $today . "' GROUP BY h.subid ORDER BY count DESC LIMIT 15 RETURNS: name imdb id owner count *Angels and Demons WT...

How to add to a MySQL table only if the record doesn't already exist?

I'm getting an array of strings from a JSON object. I want to save these strings in a DB, but only if they're not already in there. What's the best way to compare what's already in the DB with what I'm about to enter, and exclude matches? I'm using PHP and MySQL. Thanks! ...

Is it possible to have a default parameter for a mysql stored procedure?

I have googled this and keep coming up with "No it is not possible" but these posts were dated 2005-2007 so I'm wondering if this has been changed. A code example: CREATE PROCEDURE `blah` ( myDefaultParam int = 0 -- This breaks the code for some reason ) BEGIN -- Do something here END One of the solutions has been to pass null and...

MySQL Login Trouble

I just set up a new MySQL 5.1 Database Server on a Windows XP Box. I set up a password during configuration. However, now I can't seem to log in using the Administrative tool or command line, but there is one inconsistency that bugs me. If I try to log in using the cmd line (mysql -u admin -p) or the MySQL Administrative Tool using th...

what does unauthenticated user mean in MYSQL?

mysql> show full processlist; +-----+----------------------+--------------------+------+---------+------+----------------------------------+-----------------------+ | Id | User | Host | db | Command | Time | State | Info | +-----+----------------------+---------...

store a pdf in mysql

How would you store a PDF document in a field in mysql? Currently I have a list of customers and each customer has a certificate with information about their account that they can give to other companies to prove that they're our customer. Currently their certificate is exported as a pdf and e-mailed to someone here at work (the custome...

Mysql Instance not available to local user account.

I installed an instance of MySQL 5.1. The service runs fine when I log on as Administrator. But I am unable to run the instance using a local user account. The instance runs in 'localhost'. I get Error 5: Access Denied when I try to start the service from the local account. Should I elevate privileges to run the service? How do I do it? ...

how to repeatedly retrieve certain amount of data from a large data set?

I have a INVENTORY table. There are many items inside. When I query it, I just want to retrieve 50 items each time, and continue to get next 50 if user request and repeat this process until end of records. I am using MySQL database. How to do it in plain SQL if possible? thanks, ...

MySQL Group by Multiple Columns on Joined Tables (WordPress)

I have this problem joining across multiple tables and grouping by columns on those tables. I spent a few hours at work today with no success, I think I have a misunderstanding of joins or multiple column grouping. I have included an SQL dump at the end of this post so you can see the database for yourself - it'll probably explain bette...

MySQL scheme database builder

I'm currently putting together (on old fashioned paper) a layout for my new database, but was told I should probably lay it out as a scheme, which is true. Is there a tool that allows me to create my table structure/scheme in a plan type layout interface with all relationships and when it's finished it automagically creates the tables i...

Trying to make an function call to an external file with PhP, MySQL using WAMP

Hello All, I'm sure there is a simple answer to this, but I have been fumbling with everything for almost a week now and surrender. I am trying to build a shopping cart app and every coding solution I build will work when I include the code on the same page, but when I try to use an external page to run the function it does not seem to r...

How do you deal with the fact that default parameters are not possible for Mysql SPs?

Any Ideas? I asked the question "Is it possible to have a default parameter for a mysql stored procedure?" today and the answer was a very strong "no this is not possible." So my next question then is how do you as a php/mysql developer handle this problem? Do you pass null and in the SP have an IF block that sets the variable if its nu...

How to get mysql random integer range?

I am trying to generate a random integer for each row I select between 1 and 60 as timer. SELECT downloads.date, products.*, (FLOOR(1 + RAND() * 60)) AS timer I have searched and keep coming up to this FLOOR function as how to select a random integer in a range. This is giving me a 1 for every row. What am I missing? I am on mysql ...

confused by insert on duplicate key update

I'm trying to implement a 3 table item tagging system Table: Item Columns: ItemID (primary, auto_increment), Title, Content Table: Tag Columns: TagID (primary, auto_increment), Title, TagCount Table: ItemTag Columns: ItemID, TagID Each Title of a tag is unique. I would like to implement an efficient way of inserting to the Tag ta...