mysql

MySQL Case in Select Statement with LIKE operator

Is it possible to combine the CASE statement and the LIKE operator in a MySQL SELECT statement? For Example, I am trying to query a database that stores data in a single column in either one of two formats (this is awful and hurts my head, but I cant change the data so it is what it is.). So sometimes the column numbers would have data ...

mysql LAST_INSERT_ID() is causing some SQL problems when passing back value retrieved...

I need some help figuring out why the following scenario does not work. I'm trying to retrieve a value from the last updated ID in mysql, then pass that value via javascript over to an ajax call which calls a .php page, which also calls another function "ZEND_emaiL" in a different php page. In the very first php page that retrieves the...

How to set an AUTO_INCREMENT field with to start with the value 6000 in mysql?

How to set a field auto increment without auto increment key in mysql or how set a field auto increment with start value 6000 in mysql? ...

Is there a comparison table showing differences between MySQL, SQLite, and PostgreSQL SQL implementations?

I believe I my understanding is correct that there is a standard SQL. I'm assuming that MySQL, SQLite, and PostgreSQL all have variable support for the standard. Can anyone point me to a comprehensive comparison table that shows the differences? ...

Count of a column with different rows

I want to join two tables (below) which i get. But then I want to do a count to see how many times each job_category is shown when contactId > 0 Any Help would be appreciated! Tablel : | JobPositionId | JobPositionName | JobDescriptionId | JobCategoryId | ContactId ----------------------------------------------------------------------...

Fastest way to populate a Db

I have an excel spreadsheet with products and categories with a many to many relationship and i need to populate the db with it. I am searching for a quick way to enter this data in and have the join table have all the correct info. I have phpmyadmin but it seems to be a bit slow unless there is a shortcut. Another approach i was thinkin...

Recursive folder listing in a drop down menu, in php

Im building a file manager which allows users to create folders within folders (within folders) to store their files. I didn't put a real limit on the depth of folders, but I'll probably make it 10 or something like that. How could I list all the folders (in a tree structure) inside the drop down menu, like so? / /Folder 1 /Folder 2 ...

Getting the Next Available Row

How can I get a List all the JobPositionNames having the lowest jobPositionId when ContactId = 1 Tablel : | JobPositionId | JobPositionName | JobDescriptionId | JobCategoryId | ContactId --------------------------------------------------------------------------------- 1 | Audio Cables | 1 | 1 ...

Dynamic Vertical menu question.

I want all my dynamic generated php links to be displayed like in example 1 below and when I click on a link which takes me to another page all its sub links are displayed like in example 2 and when I click on one of those links all its sub links are displayed like in the rest of the examples. I'm using PHP, MySQL and Jquery for my we...

Who is my slave database's master?

I'm trying to set up replication on a couple databases and have just run the change master command. I got very little feedback from the command: Query OK, 0 rows affected (0.07 sec) I want to know whether this step has succeeded or not. So, is there a way to find out who my slave db thinks is its master? Thanks. ...

Change to a cyclic unlimited while loop

I have a photo gallery that has a previous and a Next link. When it gets to the last image it stops there. I want it to start over at the first picture. The function is a for loop and I think it should be a while loop and some things changed to make it an infinite loop. I just don't know how to convert this function. Still not that stron...

Select all projects that have matching tags

I'm trying to find the most efficient way of dealing with this but I must tell you front-head I've made a mess of it. Looked around SO and found nothing of relevance so here it goes. How to select all projects that have similar tags to the desired project? Take this table for example: (sql code to recreate tables bellow) project 1 -...

which mysql library should i use in php and why

I have been using php for quite a sometime now and encounter three different interfaces viz. mysql_*, mysqli_* and PDO to connecting with mysql database. What i am not able to understand is why to have so many interfaces for the same.. if one is better then which one?? or is it a matter of choice between select one or other. Does there e...

Performance GROUP_CONCAT on MySQL

Hi, i was trying to optimize some queries on my MySql Db when i found myself in a doubt. The problem: two similar queries produce almost the same result but the one I tought would be more expensive it isn´t, Having this table: CREATE TABLE `da_video_votes` ( `video_id` int(10) NOT NULL, `user_id` int(10) NOT NULL, `type` enum('l...

Mysql Correctly compare 2 datetimes ?

Hello, I have an issue that i'm about to pull my hair out over, ok let me start. I'm using php and mysql i have a database that holds rows with information and one of the columns has a datetime field in a 24hr format. I am trying to retrieve information using the following query: SELECT * FROM `table` where `new` != '1' AND `time...

how to store registered and guest session login in mysql

hi, i have a highscore system in that i have small doubt like i want to store the user session in the mysql table and also the guest session. like if the user is registered user then that session should be stored in the mysql db. else if the user is not registered i.e guest user then also i need to store with the guest account for my hig...

SQL Select Statement with WHERE, AND, OR

Hi guys, I would like to perform a SELECT query with MySQL. My goal is to select all the dogs in a vet database that would be sex=male and fur=short and (color=black or size=big) Note: I want to select dogs that are either black or size are big. They don't have to fulfill the 2 requirements. They just need to fulfill either one. I have...

Crystal report shows database login requirement?

Hello All, I have created a crystal report using MySql 5.1, using XML (Dataset save as xml in application root folder) now when i run on my machine it works fine. But when app is installed on other machine it give database login required. how can i remove that login window ? The code is given below cDataSet.DataSetNam...

Expain the result of "explain" query in mysql

I am using indexing for mysql tables. My query was like this EXPLAIN SELECT * FROM `logs` WHERE userId =288 AND dateTime BETWEEN '2010-08-01' AND '2010-08-27' I have indexing on field userId for this table logs, and the result of explain query is like below. id select_type table type possible_keys key key_len r...

ajax validation with multiple input fields

hi guys, I am working on a new system and am stuck at a point with jquery + ajax. My problem is this, how can i validate multiple fields in my registration form using ajax. I don't want to create a separate validation for each input fields. can you help me guys, please. :-( Thanks a lot. ...