mysql

PHP and MySQL - Printing rows matching a column value

Hello, I need to write a PHP script that will print out results from a MySQL database. For example, say I have 9 fields. Field 1 is an auto increasing number, field two is a three digit number. I need to be able to have a script read, find the matching number (it'll be from a POST), and then display all matching three digit results, a...

Basic join query understanding

I know this very silly, but can anybody help me in understanding what does this join query is doing in elabortive description? SELECT j1.* FROM jos_audittrail j1 LEFT OUTER JOIN jos_audittrail j2 ON (j1.trackid = j2.trackid AND j1.field = j2.field AND j1.changedone < j2.changedone) WHERE j1.operation = 'UPDATE' AND j1.trackid=$t_id...

How to Check for record existence and do Insert in MYSQL ?

How to Check for record existence and do Insert or Update in MYSQL ? I have a script, which has set of Insert statements for multiple tables. Now when i try to execute the Insert statement, i want to do the following: Check for the record existence and then do Insert or Update. If the Record is not exist do Insert. If the Record is a...

how to diffrentiate between same field names of two tables in a select query??

i have more than two tables in my database and all of them contains same field names like table A table B table C field1 field1 field1 field2 field2 field2 field3 field3 field3 . . . . . . . . ...

MySQL: Get unique values across multiple columns in alphabetical order

Hey everyone, If my table looks like this: id | colA | colB | colC =========================== 1 | red | blue | yellow 2 | orange | red | red 3 | orange | blue | cyan What SELECT query do I run such that the results returned are: blue, cyan, orange, red, yellow Basically, I want to extract a collective list of distinct val...

Move node in Nested Sets tree

Hi everyone, I am working on an adjacency list with mySQL and can not (atleast by myself) do the thinking needed to make a decent enough query to be able to move a set of nodes (together with eventual children nodes) around. The table has following columns: id name left right Thanks a lot! ...

Adobe AIR & PHP + MySQL

Hello. I am looking for a possibility to run a PHP + MySQL solution on a desktop. Can Adobe AIR accomplish that for me? Will the setup be able to access the COM port of the computer? ...

Changing the status of a field in PHP after a period of time

Hi, For example I made a reservation for a restaurant and it expires in 24 hours. In the reservation table of the db (MySQL), how do I automatically update the status to expired after 24 hours? What approach would you guys suggest? Thanks in advance! ...

How do I modify the hundards of records based on my query result?

Hi, I inserted some error record to my table, I can query via the sql below and found hundards of record marked with half. SELECT * FROM `marathon` WHERE gender = 'male' && distance = 'half'; How to write a SQL then I can modify the result rows distance from 'half' to 'full'. Thank you. ...

SQL GROUP BY with "default values"

I'm trying to create SELECT statement with a GROUP BY clause, which should return "default values". Imagine the following simple MySQL table: CREATE TABLE `tracker` ( `id` INTEGER PRIMARY KEY auto_increment, `date` DATETIME NOT NULL, `customer_id` INTEGER NOT NULL ); The table contains only one record: INSERT INTO `tracker` (`...

mysql to active record

hi! having the following models, Contact has_many :group_contact_classifications has_many :groups, :through => :group_contact_classifications GroupContactClassification belongs_to :group belongs_to :contact Group has_many :group_contact_classifications has_many :contacts, :through => :group_contact_classifications i just want to con...

problem to find out the string is null or not

in mysql default null value is (NULL) when i try to use it in c# that code not work because it is a string who have a value "(NULL)" how i can check that string is null or not. if i check by string.insnullorempty or ==null it's not worked how can i check this row is null or not in c# ...

4 Minute Delay Between New User Registration and Receipt of Activation Email

Hello, I am using a PHP/MySQL login script that sends a new user an activation email. When a new user registers, the info is put into MySQL pretty much instantly, but then it takes about 4 minutes for the activation email to arrive in the new user's inbox. It seems like sites like Facebook and Twitter can get out an activation email i...

How do I format a date column in MySQL?

My query returns the row value as "2/27/2010 12:00:00 AM" but I need to get "2/27/2010". What do I use to get the format as I need it for MySQL? ...

Can PHP's PDO be limited to a single query?

PHP's PDO allows multiple querys to be executed at once, either via the query() method or as a prepared statement. Both of the following examples work: // Two SQL queries $query = "SELECT * FROM table; DROP table;" // Execute via query() $pdo->query($query); // Execute via prepared statement $stmt = $pdo->prepare($query); $stmt->execu...

Require reasonably random results from an SQL SELECT query within a Joomla article (Cache enabled)

Setup: Joomla website on LAMP stack I have a MySQL table containing some records, these are queried by a simple SELECT on the Joomla article, as pasted below. This specific Joomla website has Caching turned on in Joomla's Global Configuration. I need to randomize the order in which I display the resultset, each time the page is loade...

Foreign keys and NULL in mySQL

Hi everyone, Can I have a column in my values table (value) referenced as a foreign key to knownValues table, and let it be NULL whenever needed, like in the example: Table: values product type value freevalue 0 1 NULL 100 1 2 NULL 25 3 3 1 NULL Tab...

What does this code mean? (c# using mysql)

Can anyone give a good explanation of this code: bool res = (Convert.ToInt32(cmd.ExecuteScalar()) > 0 ? true : false); ...

Last results submitted in mysql db

How would i get the last 20 results submitted in a mysql db row. I need the 20 most recent user submitted results. Cheers. ...

MySQL/PHP: How to insert logged in user id into another table that is gathering data from a form that the user is inputting.

For the first time I am needing to join information from two tables and am quite nervous about doing it without any advice first. Basically, I am building a secure site that is accessed by authorised users. I have my login table with user_id, username, password Once the user is on the site, they have the option of inputting data into ...