mysql-query

Magento: select from database

hi there, I am working on my first module for magento version 1.3.2.3. I have created a simple table (not EAV, just a primary key and 2 columns) and some classes to access it, following Alan Storm's articles which helped me a lot, but I can't figure out how to make a simple select: Alan explains how to load with the primary key, but not ...

Is it possible to preload an entire MyISAM dataset using PHP & jSon?

For Example Let say we have 1000 products in a single category. And we would like to Filter through these products. As we Filter through the products using json. Each time we have need run a separate query to the DB. We were wondering if any one knows if it's possible display a preload the products table. For example preload bar: ini...

Grouping fields by category and arranging by date, and calculating from another table

I have a products table, with the fields product, category and cost, of type varchar, varchar and decimal. I then have a sales table, with the fields client, productname, quantity, cost, and saledate, of type varchar, varchar, int, decimal and date. I also have a purchases table, with the fields purchasedate, cost, quantity and purchas...

MySQL - Specialized Order By?

Hello. Is there a way to specify a sorting procedure for ORDER BY, or some kind of custom logic? What I need is to check some other data for the column being ordered, which is also in the row. For example if one column has a higher value than another, but a certain condition isn't met, it's sorted as lower. Right now I pull all the dat...

SQL statement to truncate all data from all tables in the database

Possible Duplicate: Truncate all tables in a MySQL database in one command? how to delete all the data from all tables in the database. ...

what does "delete from table where NULL = NULL" means ?

what does "delete from table where NULL = NULL" means ? ...

MySQL date difference

I am using MySQL and PHP, and I want to find the difference between two dates. I have a table named advertisers, which has a field web_start_date. I want to select all entries where the web_start_date is less than 30 days from the current date ...

How do you use MySQL spatial queries to find all records in X radius?

I have a table in a MySQL database with a spatial geometry column of type POINT. I'd like to be able to take a point at the center of a map and find all records within X miles (or whatever distance) of it. I can't seem to find a good example or explanation of how to do this that doesn't get heavily into geometric math. I'm happy to go th...

my.cnf mysql phpmyadmin

Hi, Problems:- Whenever I try to select all tables in a database the connection is just lost and unknown error is given by the server to the browser and the browser just reloads with its own error page stating that the server gave unknown error. (This is in phpmyadmin) I tried to solve this by adding max_allowed_packet to my.cnf first ...

Insert the rows of 'report_temp' which are not in 'report'?

I've two tables : report (reportID, VendorName, VendorID, MfgDate, PurchaseDate, etc.,) In report table reportID is primary key. report_temp has the same set of columns as report, but not any constraints. I've to insert the rows from report_temp to report where the reportID is not the same. I've written as INSERT INTO report(rep...

Why is this MySQL JOIN statement returning more results?

Hello, I have two (characteristic_list and measure_list) tables that are related to each other by a column called 'm_id'. I want to retrieve records using filters (columns from characteristic_list) within a date range (columns from measure_list). When I gave the following SQL using INNER JOIN, it takes a while to retrieve the record....

Simple Foreign key / Create View question

What am I doing wrong? I need to create the foreign key but the code begining at CONSTRAINT is wrong somehow, also I need help with my view I think im doing the subquery wrong can you help me? CREATE TABLE dealer( dealershipId CHAR(10), phone CHAR(10), dealershipName CHAR(10), webAddress char (10), street CHAR (10), city char (10), zip ...

mysql insert escape

I currently have this code $main_cat = "Antiques-collectables"; $mcat = "0187-1443"; $sub_cat = "toys"; mysql_query(" INSERT INTO categories (id, main_cat, sub_cat, mcat) VALUES ('', '$main_cat', '$sub_cat', '$mcat') "); For some reasons the $mcat value is not stored properly . When I check it in the database it appears as "1" ...

can't turn off mysql query cache on mac (macports install)

I'm trying to turn off mysql query cache on my local mac dev machine. I've tried via the CL: SELECT sql_no_cache; RESET query cache; SET SESSION query_cache_type = OFF; and also in the config: query-cache-type = 0 I installed it via macports. There are about 10 my.cnf files so maybe I'm not even editing the correct on? /private/e...

Single DB query for fetching the business days (mysql)

Hi, I would like to know if it's possible to fetch X no of business days (date datatype) via a single DB call in mysql. The list of holidays are stored in a table. So, the days (starting from CURDATE) which do not have entries in that table are considered to be working days. Thanks! ...

Can this Mysql query be amended to display invoice only once for the same idinvoice

The query below SELECT <output name="c.name" title="Name" />, <output name="c.reference" title="Reference No." />, <output name="i.idinvoice" title="Invoice ID" />, <output replace="(SUM(v.quantity * s.charges))/COUNT(i.idinvoice)" />As Invoice <output replace="p.amount" />AS Amount, <output replace="p.idpayment" title="Payment ID" />, ...

SQL 'Like' causing duplicate content

Hey all I am using MySQL and the 'like' query in order to find pages. I need to be able to do things this way, but this means that these pages will be the same: www.mysite.com/blog/hello-world www.mysite.com/blog/hello-worl They both work, and bring up the same page. How (possibly using .htaccess?) can I get around this problem? :\ ...

if clause in mysql

i want a simple example of if clause in mysql. i don't want to consider else case,only if clause ...

MySQL query - select postcode matches

Hello I need to make a selection based on the first 2 characters of a field, so for example SELECT * from table WHERE postcode LIKE 'rh%' But this would select any record that contains those 2 characters at any point in the "postcode" field right? I am in need of a query that just selects the first 2 characters. Any pointerS? Thanks...

MYSQL NOW() behind by 30 seconds

When I do a query for NOW() mysql returns a time that is off by roughly -30 seconds from the current time on the server. Any ideas? I tried looking through the config file and found nothing. I'm running version 5.1.37 SELECT NOW() ...