mysql

php mysql search in 2 columns in 2 tables.

Hey, I have two tables in one DB, one called Cottages and one called Hotels. In both tables they have the same named fields. I basically have a search bar that i want it to search in both of the fields in both of the tables. (the two fields being called "Name" and "Location" SO far I have $sql = mysql_query("SELECT * FROM Cottages W...

Does this mySQL Stored Procedure Work?

Hi, I got the following stored procedure from http://dev.mysql.com/doc/refman/5.1/en/functions-that-test-spatial-relationships-between-geometries.html Does this work? CREATE FUNCTION myWithin(p POINT, poly POLYGON) RETURNS INT(1) DETERMINISTIC BEGIN DECLARE n INT DEFAULT 0; DECLARE pX DECIMAL(9,6); DECLARE pY DECIMAL(9,6); DECLARE ls...

MySQL to fill in missing dates when using GROUP BY DATE(table.timestamp) without joining on temporary table

Hello, after reading through a couple similar Qs/As I haven't quite found the solution I'm looking for. The table data I have is GROUP BY DATE(timestamp) and returning a count, example result: [timestamp] => 2010-05-12 20:18:36 [count] => 10 [timestamp] => 2010-05-14 10:10:10 [count] => 8 Without using a temporary table, or calendar ...

how to have defined connection within function for pdo communication with DB

hey guys I just started trying to convert my query structure to PDO and I have come across a weird problem. When I call a pdo query connection within a function and the connection is included outside the function, the connection becomes undefined. Anyone know what I am doing wrong here? I was just playing with it, my example is below. i...

MySQL: order by and limit gives wrong result

MySQL ver 5.1.26 I'm getting the wrong result with a select that has where, order by and limit clauses. It's only a problem when the order by uses the id column. I saw the MySQL manual for LIMIT Optimization My guess from reading the manual is that there is some problem with the index on the primary key, id. But I don't know where I s...

MySQL: Updating entry WITHOUT updating timestamp

I have a timestamp in a mysql table with attribute "ON UPDATE CURRENT_TIMESTAMP". Is there a way to manually disable updating the timestamp on a special occasion? (eg: updating the entry to revise a blog post, but not to re-date it) ...

Online booking system with php

Im looking for any tutorial for online booking and reservation using php and mysql. I cant find so much from google. ...

output all data from db to a php page

Hi, I'm a real beginner with PHP & mysql. Just for studying and for a simple example at school I would like to work this simple query and possibly output all the rows (or maybe even one) to a very basic output on a php page: <?php $user= "root"; $host="localhost"; $password=""; $database = "PetCatalog"; $cxn = mysqli_connect($host,$user...

SQL query - choosing 'last updated' record in a group, better db design?

Hi, Let's say I have a MySQL database with 3 tables: table 1: Persons, with 1 column ID (int) table 2: Newsletters, with 1 column ID (int) table 3: Subscriptions, with columns Person_ID (int), Newsletter_ID (int), Subscribed (bool), Updated (Datetime) Subscriptions.Person_ID points to a Person, and Subscription.Newsletter_ID points t...

How to lookup data based on the next sunday of the week

I need to lookup a row of data from MySQL based on the next Sunday of the week. Anyone know how? ...

Importing old mysql data folder

After a reinstall, all of the old data still shows inside the MySQL/data folder, but is not actually loaded into the database. Is there any way to have MySQL scan it's data folder and / or reimport the old folders it has from its previous install? [Some data was changed after the last backup / export - partially my fault - so I would r...

Create new table with Wordpress API

I'm trying to create a new plugin to track popular posts based on views and I have everything done and ready to go, but I can't seem to create a new table using the Wordpress API (I can do it with standard PHP or with phpMyAdmin, but I want this plugin to be self-sufficient). I've tried several ways ($wpdb->query, $wpdb->get_results, d...

what mysql table structure is better

I have very complicated search algorithm on my site, so i decided to make a table with cache or maybe all possible results. I wanna ask what structure would be better, or maybe not the one of them? (mySQL) 1) word VARCHAR, results TEXT or BLOB where i'll store ids of found objects (for example 6 chars for each id) 2) word VARCHAR, resu...

calculated column or stored procedure or just php function needed ?

I have an order table in MySQL database, having a field/column which stores the date timestamp of when the order was placed. I need to calculate when the order must be shipped. I could probably figure out how to write a function to calculate the ship date and call that when ever needed but I think, not sure it may make more sense to ha...

How to display multiple categories and products underneath each category?

Generally there is a category menu and each menu links to a category page where shows all the items under that category. Now I need to show all the categories and items underneath with PHP/MySQL in the same page. So it will be like this. Category 1 description of category 1 item 1 (some details, such as name, thumbnail etc for each it...

SQL: find entries in 1:n relation that don't comply with condition spanning multiple rows

I'm trying to optimize SQL queries in Akonadi and came across the following problem that is apparently not easy to solve with SQL, at least for me: Assume the following table structure (should work in SQLite, PostgreSQL, MySQL): CREATE TABLE a ( a_id INT PRIMARY KEY ); INSERT INTO a (a_id) VALUES (1), (2), (3), (4); CREATE TABLE b ...

Sql Select Query Question. Merge Rows

I have a single MYSQL Question and need help ASAP. Database: ------------------------------------------------------------------- Email | Name | Tag ------------------------------------------------------------------- [email protected] |Test Person | TagOne [email protected] |Test...

Test a database conection without codeigniter throwing a fit, can it be done?

I'm just about finished my first release of automailer, a program I've been working on for a while now. I've just got to finish writing the installer. Its job is to rewrite the codigniter configs from templates. I've got the read/write stuff working, but I'd like to be able to test the server credentials given by the user without codingi...

how many index per database table?

Hi, How many indexes is preferred for one table in MYSQL?? I have a company table where I search mostly for ID,state and category? Thansk ...

Difference of two series in MySQL

I have a table with the following fields in MySQL: date, Value, Type. Type can be either exports or imports. I want a query that returns the trade deficit (exports-imports) for each month. Is this possible with a single query? ...