Hi, sorry for formatting this wonky but hope you can understand it.
I have two MySql tables, and I want to find and replace text strings in one using data in another.
Texts - one column: messages
'thx guys'
'i think u r great'
'thx again'
' u rock'
Dictionary - two columns: bad_spelling, good_spelling
'thx' 'thanks'
' u ' ' you '
' r ...
Why this query doesn’t working:
SELECT name
FROM
(
SELECT name
FROM table1
UNION
SELECT name
FROM table2
) q
It returns nothing, even no error or empty table.
But
SELECT name
FROM table1
UNION
SELECT name
FROM table2
Is ok. It returns table with name field full of rows from two tabl...
SELECT 1 FROM (SELECT 1 FROM table) q
does not working on my local server. it returns totally nothing (no error or empty table).
But SELECT 1 FROM table is ok.
What is wrong with it? is there any MySQL option for such queries?
...
i use this statement for a single where condition
('SELECT * FROM users WHERE id = ?', 1)
if I want to check two conditions, how would I do that
('SELECT * FROM users WHERE id=? AND age=?', 1,23)- is this correct?
...
I'm trying to LEFT JOIN two tables, to get a list of all rows from TABLE_1 and ONE related row from TABLE_2. I have tried LEFT JOIN and GROUP BY c_id, however I wan't the related row from TABLE_2 to be sorted by isHeadOffice DESC.
Here are some sample tables
TABLE 1
c_id Name
----------------
1 USA
2 Canada
3 Engla...
I have a reviews/ratings web application, a la Digg. My django app content has the following model:
class Content(models.Model):
title = models.CharField(max_length=128)
url = models.URLField(max_length=2048)
description = models.TextField(blank=True)
class Recommendation(models.Model):
user = models.ForeignKey(User)
...
I need a "find nearest location" on our website.
Where visitor enters their zip/postal code, then they are redirected to specific webpage for our nearest location. We have forty USA and Canada locations.
How can I build something like this? Could I do this with the Google Maps API? I already have a custom map on Google Maps. It's plo...
I've look around a bit and can't quite find an answer to my problem:
I want a trigger to execute after an insert on a table and to take that data that is being inserted and do two things
Create a new table from the client id and partner id
Insert the 'data' that just was inserted into the new table
I am fairly new to the Stored proc...
If I try this statement:
INSERT INTO TerminalEventChild (id,stringValue) VALUES
(64,'version123|');
MySQL fail with :
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''version123' at line 1
SQLState: 42000
ErrorCode: 1064
If I remove the ...
I have a simple flat comment system and I would like to expand it to allow one level of replies to the root level comments. I would also like to be able to have the results sorted by the root level comment in ASC or DESC order or some kind of rank but the child replies sorted always by newsest first and then still be able to select resul...
This code works fine to find an available room within certain date, but it does not work to show a room that has been booked and canceled
The "hotel" has 4 rooms and 1 of them has been booked an canceled
So even if I make a cancelation, the select method keeps giving me 3 results. Maybe because the second AND is still running. So bas...
I need UNION two tables with creating new field, where 1 for first table, and 2 for second.
I tried
(
SELECT field, 1 AS tmp
FROM table1
)
UNION
(
SELECT field, 2 AS tmp
FROM table2
)
But in result, tmp field was full of "1".
How it can be implemented?
...
Hi friends,
This is one of the most bizarre errors I've come across. So I've written a little file upload web app for my friend and it works fine for any file less than or equal to 742kB in size. Needless to say, I arrived at this precise number based on relentless testing.
Weird part is that if the file size is just a few KB more, fo...
We want to store product prices and weight (kg/pound) in MySQL. Can somebody tell me what's the best way to do this?
double/decimal/... ?
We need to be able to display both USD and EURos.
I don't know if it helps, but we use the Zend framework to build our application.
Thank a lot!
...
I have table:
id name type
where "type" is 1 or 2
I need to join this table with two other. Rows with "type = 1" should be joined with first table, and =2 with second.
For example, main table contains some events that peoples did. Fist table to join is information about mans, and second is about women. Type is sex.
I need take las...
Pretty basic question.. I kno.., I just don't know how its done.
I see it everywhere. I want to be able to sort out my content in my websites by most viewed, most commented, most popular, best rating, etc...with a drop down list, check box, etc... but I don't know how "sort by" works? Which scripting language should it be written in? Ja...
Hello,
Having a hard time figuring out the best way to do this...
I have a search function that takes "search terms" and "search location". In the location input, I have an suggestion feature that brings up "city, state abbreviation" but it seems some users just do not use it(or can't) so they end up entering just a city name... I need...
I keep getting this error while trying to modify some tables. Here's my code:
/** <- line 320
*
* @param array $guests_array
* @param array $tickets_array
* @param integer $seat_count
* @param integer $order_count
* @param integer $guest_count
*/
private function book_guests($guests_array, $tickets_array, &$seat_count,
...
Hi!
Since foreign keys are not supported by partitioned mySQL databases for the moment, I would like to hear some pro's and con's for a read-heavy application that will handle around 1-400 000 rows per table. Unfortunately, I dont have enough experience yet in this area to make the conclusion by myself...
Thanks a lot!
References:
h...
All rows in a table have a type field which is either 0 or 1.
I need to count rows with 0 and with 1 in one query. So that result should look something like:
type0 | type1
------+------
1234 | 4211
How can this be implemented?
...