‏إظهار الرسائل ذات التسميات query. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات query. إظهار كافة الرسائل

الأحد، 5 يناير 2014

Simple SQL query with MAX()

I'm new to SQL and I need some help with this task:

Database schema:

Comic(no primary key NOT NULL, title, pages, publisher)PoweredPerson(alias primary key NOT NULL, firstname NOT NULL, lastname, evilness_level)SuperHero(alias primary key?PoweredPerson NOT NULL,cape)SuperVillain(alias primary key?PoweredPerson NOT NULL)FightIn(comic primary key? Comic NOT NULL,hero primary key? SuperHero NOT NULL,villain primary key? SuperVillain NOT NULL)

Now I shall declare a SQL query which gives the first and last names of those powered person(s) that fought the most enemies in just one comic.

My solution is this:

SELECT firstname,lastnameFROM fightIn f JOIN poweredperson pON f.hero = p.alias OR f.villain= p.aliasGROUP BY comic,aliasHAVING COUNT(alias)=(SELECT COUNT(alias) FROM fightIn f JOIN poweredperson p ON f.hero = p.alias OR f.villain = p.alias GROUP BY comic,alias ORDER BY COUNT(hero) DESC LIMIT 1)

I want to know if my solution is correct and in case it is, whether there is a much smarter and shorter way to solve this.

Thanks in advance =)


View the original article here

Media screen query not working in iPhone

It looks like you simply have to put the iPhone-5 rule below the iPhone-4 one. Otherwise the css iPhone-4 rule with override the iPhone-5 one by your max-width definition. You have them backwards right now.

And don't use !important here, it will likely mess up the cascading styles. If you have !important on your iphone 4 rule that's overriding the one you have here even in the right 4 then 5 order.

And are you sure that you have your meta viewport set in the ?

To address the pixel density you need to make sure you have:


View the original article here

الثلاثاء، 24 ديسمبر 2013

Spatial query w/o spatial data

I trying to execute a next query on Oracle Database 11g Enterprise Edition (11.1.0.6.0):

SELECT "__ItemId"FROM "Cities"WHERE "Longitude" IS NOT NULL AND "Latitude" IS NOT NULL AND SDO_ANYINTERACT(SDO_GEOMETRY('POINT(' || "Longitude" || ' ' || "Latitude" || ')'), SDO_UTIL.FROM_WKTGEOMETRY('POLYGON ((-100 80, 100 80, 100 -80, -100 -80, -100 80))')) = 'TRUE'

Where "Longitude" and "Latitude" - numeric [NUMBER(28,5)] columns in the "Cities" table.

I get an error:

Error report -SQL Error: ORA-13226: interface not supported without a spatial indexORA-06512: at "MDSYS.MD", line 1723ORA-06512: at "MDSYS.MDERR", line 8ORA-06512: at "MDSYS.SDO_3GL", line 71ORA-06512: at "MDSYS.SDO_3GL", line 23913226. 00000 - "interface not supported without a spatial index" *Cause: The geometry table does not have a spatial index. *Action: Verify that the geometry table referenced in the spatial operator has a spatial index on it.

Questions:

How can I check, that point with specified "Longitude" and "Latitude" in the specified polygon? Polygon in not always simple, it can be any.How can I create a spatial index on a table without any spatial column?It's really, I can not just call a spatial operator?

View the original article here

الجمعة، 20 ديسمبر 2013

How to make this SQL query faster

I have two tables like

table1:

word ida 1a 2a 10c 20d 21e 30

table2:

id1 id21 202 21

Now if word='a' then I need to find out 'c' and 'd' using table1 and table2: I wrote a query, its working but taking too much time, because tables include huge data.

Query:

SELECT word FROM table1 WHERE id IN (SELECT id2 FROM table2 WHERE id1 IN ( SELECT id FROM table1 WHERE word = 'a'))

Another query:

SELECT DISTINCT word FROM table1 WHERE id IN (SELECT id FROM table1 WHERE word = 'a')

View the original article here

mysql query and encoding it in json format

I'm using this simple php code to encode the MySql query result in json format. But Don't know why it is not giving me the desirable output. I'm actually trying to get the employee details by entering their 'employee_number'.

0) { $result = mysql_fetch_array($result); echo("Success !! Yoo"); $employee = array(); $employee["employee_number"] = $result["employee_number"]; $employee["employee_name"] = $result["employee_name"]; $employee["flag"]=$result["flag"]; // success $response["success"] = 1; // user node $response["employee"] = array(); array_push($response["employee"], $employee); // echoing JSON response echo json_encode($response); } else { // no employee found $response["success"] = 0; $response["message"] = "No employee found"; // echo no users JSON echo json_encode($response); } }else { // no employee found $response["success"] = 0; $response["message"] = "No employee found"; // echo no users JSON echo json_encode($response);}/*} else {// required field is missing$response["success"] = 0;$response["message"] = "Required field(s) is missing";*/// echoing JSON responseecho json_encode($response);?>

View the original article here