mysql

sql jdbc getgeneratedkeys returns column "id" not found, column type unknown

I want to retrieve the most recently updated value in the table using an insert query. these are the datatypes in my sql table. int(11) // primary key auto increment, not being assigned by sqlQuery varchar(30) timestamp // has a default value. but i am explicit assigning it using CURRENT_TIMESTAMP varchar(300) varchar(300) varcha...

What's wrong with this SQL query?

I have two tables: photographs, and photograph_tags. Photograph_tags contains a column called photograph_id (id in photographs). You can have many tags for one photograph. I have a photograph row related to three tags: boy, stream, and water. However, running the following query returns 0 rows SELECT p.* FROM photographs p, photograph...

how so select similarities in MySQL?

Currently, I am doing a search function. Lets say in my database, I have this data: Keyword1 Keyword2 Keyword3 Keysomething Key and the user entered: "Key" as the keyword to search. This is my current query: Q1: SELECT * FROM data WHERE (data_string LIKE '$key%' OR data_string LIKE '%$key%' OR data_string LIKE '...

Best way to use number format in mysql query

can any one please let me know, i need to set the "Total Price" value to be in two decimal point value like "56.35". Now its showing more fraction values like "56.3566666". I need it to be format it by musql "SELECT" query. ...

HOw Do I update from table-2 to table-1

HI what is the wrong in this code?? i have set it 24 hours to update the value in the table.but the problem is if $row is empty then it inserts value from table-2 but after 24 hours it wont update the value. what I want is it must delete the existing value and insert new one(random value) or it must update the same $row with new value w...

my sql insert query not working

I am inserting userId.It is displaying correct but inserting 0 in spite of actual userId. mycode- If(! empty($userIDToCheck) || $userIDToCheck != '' ) { echo $userIDToCheck; $sql = "INSERT INTO `pnpdb`.`ruser` (`userid`) VALUES ('$userIDToCheck');"; mysql_query($sql)or die(mysql_error()); echo "Done"; } Output : pi203713 Done...

which is the best optimizaton method in MySQL

Suppose I have 1 million data in my database. what will be the most optimized criteria to get faster results?? Criteria 1: Single database - Many tables Criteria 2: Multiple database - Multiple tables Criteria 3: Single database - Single table and what are the other factors which I need to take care off?? Thanks Mathew ...

How can I use an array within a SQL query

So I'm trying to take a search string (could be any number of words) and turn each value into a list to use in the following IN statement) in addition, I need a count of all these values to use with my having count filter $search_array = explode(" ",$this->search_string); $tag_count = count($search_array); $db = Connect::connect(); $qu...

What is the best way to use MySQL full-text search with a self-join?

I want to do something like: select a.a_ft,count(b.a_ft) FROM row a JOIN row b on match a.a_ft against (b.b_ft). However, this isn't legal. Basically, I just want to look for similar phrases in my database. What is the easiest way to do this? ...

Mysql Left join with condition on column

Hi, can you help me with sql query? I have this problem: I have two tables "Join" table: Reservation_has_meal +----------------+ | id_reservation | | id_meal | | pieces | +----------------+ and table with data: Meal +-------------+ | id_meal | | name | +-------------+ Sample data for Meal: 1 | carrot...

Match two mysql cols on alpha chars (ignoring numbers in same field)

I was wondering if you know of a way I could filter a mysql query to only show the ‘alpha’ characters from a specific field So something like SELECT col1, col2, **alpha_chars_only(col3)** FROM table I am not looking to update only select. I have been looking at some regex but without much luck most of what turned up was searching ...

How do I load Individual Div without load entire page and show loading status??

Hi How can I load individual Div separately without affecting current page and show loading status for that div with PHP and MySQL or Ajax and SQL ...

PHP PDO fetch null

How do you check if a columns value is null? Example code: $db = DBCxn::getCxn(); $sql = "SELECT exercise_id, author_id, submission, result, submission_time, total_rating_votes, total_rating_values FROM submissions LEFT OUTER JOIN submission_ratings ON submissions.exercise_id=submission_ratings.exercise_id WHERE id=:id"; $st = $db->p...

What is MySql equivalent of Sql Server Full Text Search?

Hello, I have worked with Sql Server in past and used it's very nice feature called Sql Full Text Search. Now i have to work with MySql. Can anybody tell me what is equivalent of Full Text Search in MySql? I am using free edition of MySql and not a commercial one. If not, then what else can we do to mimic Full Text Search and get over th...

MySQL AND alternative for each table in a join

I have a simple join in a query however I need to have a condition on both of the tables "confirmed='yes'" but if one of the tables doesn't have any that match the query returns with no rows. Database: .----------parties----------. | id - party_id - confirmed | |---------------------------| | 1 1 yes | | 1 2 ...

MySQL Subquery LIMIT

As the title says, I wanted a workaround for this... SELECT comments.comment_id, comments.content_id, comments.user_id, comments.`comment`, comments.comment_time, NULL FROM comments WHERE (comments.content_id IN (SELECT content.content_id FROM content WHERE content.user_id = 1 LIMIT 0, 10)) Cheers ...

Optimize GROUP BY&ORDER BY query

I have a web page where users upload&watch videos. Last week I asked what is the best way to track video views so that I could display the most viewed videos this week (videos from all dates). Now I need some help optimizing a query with which I get the videos from the database. The relevant tables are this: video (~239371 rows) VID(in...

How can I check data has been inserted successfully?

I have two insert statements. The second one will be executed only after successful execution of first one. What I would like to do is: $sqlone="Insert into ....."; $sqltwo="Insert into....."; If (mysql_query($sqlone)) { If (mysql_query($sqltwo)) { Show message Data inserted in both tables. } } ...

Why I am not able to update the column based on a condition which is not the primary key

Why I am not able to update the column based on a condition which is not the primary key. I am trying to update the constituencies table where name matches a specific criterial as shown below but the below queries shows an error Error code 1064, SQL state 42000: You have an error in your SQL syntax; check the manual that correspond...

Hibernate doesn't generate cascade

Hi. I have a set hibernate.hbm2ddl.auto to create so that Hibernate creates the tables in mysql for me. However, it doesn't seem that hibernate correctly adds Cascade on the references in the table. It does however work when I for instance delete a row, and I have a delete cascade as hibernate annotation. So I guess that means that Hib...