mysql

How to implement LIMIT with Microsoft SQL Server?

I have this query with mysql : select * from table1 LIMIT 10,20 How can I do this with Microsoft sql ? ...

MySQL: Simple way to toggle a value of an int field

I know how to do this, but i think I'll overcomplicate it with double selects and so on. How can you do this (example in pseudo-sql) UPDATE some_table SET an_int_value = (an_int_value==1 ? 0 : 1); It must be an int value due to some other functionality, but how do you do it in a simple way? ...

mysql queries crawl when switching servers

I ran into a problem last week moving from dev-testing where one of my quieries which had run perfectly in dev, was crawling on my testing server. It was fixed by adding FORCE INDEX on one of the indexes in the query. Now i've loaded the same database into the production server (and it's running with the FORCE INDEX command, and it has...

How do I join tables on an update

I have the following query: select count(L.ID) from LA inner join L on (LA.leadid = L.ID) where L.status = 5 and L.city = "cityname" and Date(LA.Datetime) < Date_Sub(Now(), INTERVAL 6 MONTH); which looks for records with status 5 in a particular city that are older than 6 months (the date for which is...

How to get a category listing from Magento?

I want to create a page in Magento that shows a visual representation of the categories.. example CATEGORY product 1 product 2 ANOTHER CATEGORY product 3 My problem is, their database is organised very differently to what I've seen in the past. They have tables dedicated to data types like varchar, int, etc. I assume this is for p...

Select from MySQL records that sums

Hello. I know there are a few post out here about selecting records until a certain number is met from the sum of one field but there isn't any that suits me. I'm using PHP and MySQL. I have a table named quantity. Inside there are records of product name, product price and product quantity. Besides these, there are a few others that he...

concat selected values in a single result row, can it be done (without grouping)?

I have the following structure: main: id | meta_data sub: main_id | another_table_id main is connected to sub in a one to many. I wish to get back my result as one record which will look like: [main_id] [meta_data] [another_table_id,another_table_id,another_table_id] Is it possible in MySql without using GROUP BY? ...

What ec2 image (ami) do you recommend for working with java 5, jboss, mysql, apache?

What ec2 image (ami) do you recommend for working with java 5, jboss, mysql, apache? ...

Does mysqli class in PHP protect 100% against sql injections?

I've seen lots of articles and questions about mysqli, and all of them claim that it protects against sql injections. But is it fool proof, or is there still some way to get around it. I'm not interested in cross site scripting or phishing attacks, only sql injections. What I should have said to begin with is that I am using prepared st...

MYSQL PHP: Check already made query for distinct field values?

I have a page that that lists products returned from a mysql query. The query can very greatly depending on many different things. What I want to do is give the user an option to narrow the current results by series of drop-downs. For example to narrow the product type. But to get the available product types I am currently just checking...

Hierarchical recursion menu with PHP/MySQL

This should (hopefully) be a pretty easy question for some of you to answer. I have a working Recursive menu from a mySQL database, now my main problem is: What is the best way to create the URL? I would prefer to bring in the title of each row like /eggs/milk/bacon/. Eggs being level 0 like: eggs-0, milk-1, bacon-2. Any ideas on ho...

How can I count the numbers of rows that a mysql query returned?

How can I count the numbers of rows that a mysql query returned? using PHP.. ...

Limiting results to a distinct column with SQL

I am attempting to get a list of items along with the order information for each item. An order always has at least 1 item associated with it. I want to limit this list to all of the items from 10 orders. As my query stands below, it gets 10 items. What is the best way to LIMIT this to 10 orders, while grabbing all of the items assoc...

Looking for advice on updating an online database with SMS

I am looking to write a small application that receives an SMS text message and records the results in an online database. I am most comfortable with php/mysql, but can use any suggestions you might have. ...

PHP&MySQL: Is it possible after running mysql_query with an insert to get the ID of the new row?

Is there a straightforward way to run mysql_query with an insert and get the ID of the new row, for example in the return? Or will I have to do another query with select to check it? ...

connecting to quickbooks database via odbc with php?

[edit] We're collecting credit application data from users on a web form. I have not tied my web form directly into QB. I have no idea what the QB table structure is for this collection of data - nor of how it displays it to the user because I've never actually worked directly with QB. Others in my office do however. I would still ...

Displaying MySQL tables as ASCII in blog posts

Hi, I would like to quickly display MySQL recordsets in blog posts, using a similar ASCII layout to that used by mysql.com in their help pages. I'm using wordpress v2.7. Any ideas? I should also add that I'm using wp-syntax for syntax highlighting, so it's really just generating the ASCII that I'm interesting in. ...

Should totals be denormalized?

I am working on a website with a simple normalized database. There is a table called Pages and a table called Views. Each time a Page is viewed, a unique record of that View is recorded in the Views table. When displaying a Page on the site, I use a simple MySQL COUNT() to total up the number of Views for display. Database design seem...

mySQL query for selecting children

Hello, I am not sure if this is possible in mySQL. Here are my tables:- Categories table - id - name - parent_id (which points to Categories.id) I use the above table to map all the categories and sub-categories. Products table - id - name - category_id The category_id in the Products table points to the sub-category id in which it ...

How do applications collect statistics?

I need to collect statistics from my server application written in python. I am looking for some general guidance on how to setup models and exactly how to store the statistics information. I was thinking of storing and organizing all this information in a database, but my implementation is turning out to be too specific. I need to co...