TOPIC_COUNT_SQL = """
SELECT COUNT(*)
FROM topics_topic
WHERE
topics_topic.object_id = maps_map.id AND
topics_topic.content_type_id = %s
"""
MEMBER_COUNT_SQL = """
SELECT COUNT(*)
FROM maps_map_members
WHERE maps_map_members.map_id = maps_map.id
"""
maps = maps.extra(select=SortedDict([
('member_count', MEMBER_COUNT_SQL),
...
i am trying to create a foreign key in my table. But when i executes my query it shows me error 150.
Error Code : 1025
Error on create foreign key of '.\vts\#sql-6ec_1' to '.\vts\tblguardian' (errno: 150)
(0 ms taken)
My Queries are
Query to create a foreign Key
alter table `vts`.`tblguardian` add constraint `FK_tblguardian` FOREIG...
I have a store procedure to get the data i want:
SELECT a.SONum, a.Seq1, a.SptNum, a.Qty1, a.SalUniPriP, a.PayNum, a.InvNum,
a.BLNum, c.ETD, c.ShpNum, f.IssBan
FROM OrdD a JOIN OrdH b ON a.SONum = b.SONum
LEFT JOIN Invh c ON a.InvNum = c.InvNum
LEFT JOIN cus d ON b.CusCod = d.CusCod
LEFT JOIN BL e ON a.BLNum = e.BLNum
LEFT JOIN ...
Explain
SELECT `feed_objects`.*
FROM `feed_objects`
WHERE (`feed_objects`.feed_id IN
( 165,160,159,158,157,153,152,151,150,149,148,147,129,128,127,126,125,124,122,
121, 120,119,118,117,116,115,114,113,111,110)) ;
+----+-------------+--------------+------+---------------+------+---------+------+------+-------------+
| id | select_t...
I have two tables: table1, table2. Table1 has 10 columns, table2 has 2 columns.
SELECT * FROM table1 AS T1 INNER JOIN table2 AS T2 ON T1.ID = T2.ID
I want to select all columns from table1 and only 1 column from table2. Is it possible to do that without enumerating all columns from table1 ?
...
Hi everyone, forgive my newbie question, but why finding by '2' or '2' in Mysql returns the same record?
For example:
Say I have a record with string field named 'slug', and the value is '2'. And the following SQLs returns same record.
SELECT * From articles WHERE slug='2'
SELECT * From articles WHERE slug='2'
...
Hi everyone,
I’m having some difficulties with a query which purpose is to give users with more than one thread (called CS) in current year a 5% point “raise”.
My relational schema looks like this:
Thread = (**threadid**, threadname, threadLocation)
threadoffering = (threadid, season, year, user)
user = (**name**, points)
Then, wha...
I have some financial values stored as text in a mysql db. the significance of financial is that negative numbers are stored enclosed in paranthesis. is there a way to automatically get the numeric value associated with that text. (like '5' shoudl be retuned as 5 and '(5)' should be returned as -5)
...
I need to load the database values into the grid view by checking the attribute "id".
If the id value which I entered is equal to database, then it'll load in the grid view.
Help me to do that
...
Hey. consider d following table and data...
in_timestamp | out_timestamp | name | in_id | out_id | in_server | out_server | status
timestamp1 | timestamp2 | data1 |id1 | id2 | others-server1 | my-server1 | success
timestamp2 | timestamp3 | data1 | id2 | id3 | my-server1 | my-server2 | success
timestamp3 | time...
I am looking for few global variable in mysql which are equivalent of sql server.
I want the whole list
eg.
Sql Server Equivalent
@@error ---
@@Identity ---
etc.
Basically right now I want to know what are the equivalent variable of @@error and @@identity.
But it will be helpfull if u could provide some other variable ...
I've got a huge bunch of flights travelling between airports.
Each airport has an ID and (x,y) coordinates.
For a given list of flights, I want to find the northernmost (highest x) airport visited.
Here's the query I'm currently using:
SELECT name,iata,icao,apid,x,y
FROM airports
WHERE y=(SELECT MAX(y)
FROM ...
Hi,
I have a SQL query
SELECT * FROM Thing AS a JOIN Thing_Property AS b ON a.id=b.Thing_ID
JOIN Property AS c ON b.properties_ID = c.id
JOIN Item AS d ON c.item_ID = d.id
ORDER BY a.name, d.name
and I Eclipselink to create my object model with it.
Here is the model:
@SuppressWarnings("serial")
@Entity
public class Thi...
how do you import data from an xml document to mysql having difficulty do this does anyone know to do this
...
Hello
I'm creating a database structure. I have to store ingoing and outgoing messages and i'm wondering wich is the best way to do this.
2 separated tables or the same tables with an ENUM('in', 'out') column ?
Any suggestion ?
Thanks.
...
Hi, using a c# asp.net page, building a SQL query string to run against an index server catalog:
string SQL = "SELECT doctitle, vpath, Path, Write, Size, Rank ";
SQL += "FROM \"" + strCatalog + "\"..SCOPE() ";
SQL += "WHERE";
SQL += " CONTAINS(Contents, '" + strQP + "') ";
SQL += "AND NOT CONTAINS(Path, '\"_vti_\"') ";
...
I have a field that indicates whether someone wars a commission or a fee.
In sql its going to be a bit field.
How should I name it?
...
I am trying to assign salespeople (rsSalespeople) to customers (rsCustomers) in a round-robin fashion in the following manner:
Navigate to first Customer, assign the first SalesPerson to the Customer.
Move to Next Customer. If rsSalesPersons is not at EOF, move to Next SalesPerson; if rsSalesPersons is at EOF, MoveFirst to loop back to...
i need to get a query where the elements are displayed in case the first letter is E (the word is electronics).. i have tried with the following :
mysql_query("select * from nested_category where name like '[A-F]%'");
Edit : its like i need to choose all the elements for which the first element lie between A & F .. I need all the ele...
I have a table which stores test results like this:
user | score | time
-----+-------+------
aaa | 90% | 10:30
bbb | 50% | 9:15 ***
aaa | 85% | 10:15
aaa | 90% | 11:00 ***
...
What I need is to get the top 10 users:
user | score | time
-----+-------+------
aaa | 90% | 11:00
bbb | 50% | 9:15
...
I've come up w...