mysql

Basic PHP entry exam

My boss just asked me to write a little test for people that are applying for a new PHP developer position here. Since this is the first time I've been told to do such a thing, I was wondering what you guys think the test should contain? I was thinking about something like a simple PHP login system: I think it covers most of the bases,...

How to generate secure passwords for new users?

I have a list of students that are being added via a form inside the admin area. I'm trying to come up with a password generating solution for each addition that will be both secure and viewable from the admin panel (like below). I need it to be viewable so that the admin will be able to print out the passwords and hand them out to th...

Current status based on single date on multiple rows

Hello all! I hope it's not a duplicate, but believe me, I've searched high and low. I have a list of user records, let's call it qualifications. Example: Row#. Date User Qualification 1 2010-07-15 1 A1X 2 2010-08-30 1 B1X 3 2009-04-01 1 C1X Now I'd like to do a query, where on a given date or date range...

Remove on update condition without drop mysql table

I have a mysql table and data entries in it: CREATE TABLE `invoices`.`invoices` ( `InvoiceID` bigint(20) unsigned NOT NULL auto_increment, `UserID` int(10) unsigned NOT NULL, `Value` decimal(10,3) NOT NULL, `Description` varchar(4048) NOT NULL, `DateTime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURR...

MySQL Batch increase value?

My client has asked me if I can update about 500 of his prices (increase by 10.00). The products are all stored in a MySQL table, can anyone give me an example SQL query that will do this? Thanks. ...

Issues with MySQL Queries on certain hosting packages.

I've been building a website on a subdomain of my companies hosting package. It's got PHP MySQL operations happening in the background, i.e. INSERTs, SELECTs etc. They are the most basic of basic SQL statements and they all work fine. However, I recently copied EVERYTHING from my subdomain and uploaded it all to my clients own hosting...

SQL (Mysql) order problem

Hi all, I have the following query: SELECT a.field_eventid_key_value, a.field_showdate_value, b.nid , c.nid AS CNID FROM content_type_vorfuehrung AS a LEFT JOIN content_type_movies as b ON a.field_eventid_key_value = b.field_eventid_value LEFT JOIN content_type_sonderveranstaltung as c ON a.field_eventid_key_value = c.fi...

MySQL Triggers - AFTER INSERT trigger + UDF sys_exec() issue

Problem: I've got a table which holds certain records. After the insert has been done, I want to call an external program (php script) via MySQL's sys_* UDFs. Now, the issue - the trigger I have passes the ID of the record to the script. When I try to pull the data out via the script, I get 0 rows. During my own testing, I came to a conc...

Mysql Compare Dates

Hello, I want to compare a date from DB that is between 2 given dates. The column from DB is DATETIME ,and I want to compare it only to date format,not datetime format. SELECT * FROM `players` WHERE CONVERT(CHAR(10),us_reg_date,120) >= '2000-07-05' AND CONVERT(CHAR(10),us_reg_date,120) <= '2011-11-10' I get this error when I execute ...

Which granulary to choose for database table partitioning?

I have a 20-million record table in MySQL database. SELECT's work really fast because I have set up good indexes, but INSERT and UPDATE operation is getting to be really slow. The database is back-end of a web application under heavy load. INSERTs and UPDATEs are really slow because there are some 5 indexes on this table and index size i...

mysql query help, getting values from table using relational id's from another table

THE SQL THAT BUILDS THE TABLES, -- -- Table structure for table `careers` -- CREATE TABLE IF NOT EXISTS `careers` ( `career_id` int(11) NOT NULL auto_increment, `career_name` varchar(75) NOT NULL, `career_desc` text NOT NULL, `degree_needed` enum('Yes','No') NOT NULL, `useful_info` text, `useful_links` text, PRIMARY K...

How to prevent GROUP_CONCAT from creating a result when no input data is present?

Given the following MySQL query: SELECT `show`.`id` , GROUP_CONCAT( `showClips`.`clipId` ORDER BY `position` ASC ) AS 'playlist' FROM `show` INNER JOIN `showClips` ON ( `show`.`id` = `showClips`.`showId` ) ; I want to retrieve a list of all "shows" from the database, including the ids of contained "clips". ...

CLSQL and MYSQL on OS X

I'm working on OS X 10.6.4. I've been using clbuild to install supporting libraries for SBCL (including clsql), and I do all my work through Aquamacs. I installed MySQL using the excellent instructions over at Hive Logic. But when I call (require 'clsql) -- which seems to work fine -- and then try to execute (clsql:connect '(nil "lisp" "...

query works in MySqlWorkbench but not in php mysql

I have the following query that works fine in MySqlWorkbench but not in php. I've copied the query exactly from php into workbench and it works fine there. Any ideas why this is happening? I can't figure it out. SELECT tlpd_games.id FROM tlpd_games LEFT JOIN tlpd_leagues league on tlpd_games.league_id = league.id where league.section_...

mysql insert command syntax

I am using MYSQL 5.1, I am trying to write an insert statement in my java class. It sounds very simple but i tried and getting exception. I am sure there is a syntax error with my code. below is the snippet could any one help me out here. ID is in primary key atm_ID is varchar trasn_id is varchar sysDate is Date rest is int please he...

Error Table 'mysql.servers' doesn't exist

I get the error "Table 'mysql.servers' doesn't exist" from plesk when I try to create a new database user, the created user does not show up anywhere but the name is still reserved, and it does not allow me to access the database. edit: I was unable to login to phpMyAdmin to this webserver, so instead I managed to login to it through a ...

MySQL record ordering

In one of my current projects I have a dropdown (select) form element. I populate the options using an array (PHP): $regions=array( 1=>'North West', 2=>'North East', 3=>'South West', 4=>'South East', ); (array key=option value, array value=option text) Now this offers me the convenience of being able to re-order the o...

Is storing a comma separated list in a database column really that bad?

Imagine a web form with a set of checkboxes (any or all can be selected). I chose to save them in a comma separated list of values stored in one column of the database table. Now, I know that the correct solution would be to create a second table and properly normalize the database. One reason was laziness, my SQL knowledge is very limi...

Is there an proper way to structure the array better for looping

OK so I have this page and as you can see I am loggering the array of 12 products. If you scroll down you can see the requirements are that i need to group them by category name but i am not sure the best way to structure the loops. my query $query = "SELECT p.name, p.price, pc.quantity, p.image, p.descr, t.name as Category_name ...

How do you avoid this race condition in Python / Django / MySQL?

I have a model MyModel that has a field expiration_datetime. Every time a user retrieves an instance of MyModel I need to first check if it has expired or not. If it has expired, than I need to increment some counter, update others, and then extend the expiration_datetime to some time in the future. So the view would do something ...