select

case statement options splitted on two output columns

狂风中的少年 提交于 2020-05-17 06:14:05
问题 I have a table with a list of functionalities for my site. Say it has three columns: id_usr - url - landing_page 1 a.php a.html 2 b.php b.html 3 c.php c.html 4 d.php d.html Then I have a table where for each user i have those functionalities he can display: id_usr - func 1 1 1 3 This query (from this question of mine) SELECT f.id, CASE WHEN id_user IS NOT NULL THEN url ELSE landing_page END FROM funzioni f LEFT JOIN funz_abilitate fa ON fa.id_funzione = f.id AND fa.id_user = $id is returning

MySQL select statement returning results in circle mode

给你一囗甜甜゛ 提交于 2020-05-16 10:57:55
问题 i am working with an app that via swipes you can see cards one after the other. Both left and right swipes are permitted. If the user swipes right he will see the next available card. If he swipes at the left he will see the previous card. The cards details are stored to a MySQL table 'Cards' and have a unique id let's say 'CardID' starting from number 1.000.000 and so on. Let's say that i currently have added 500 cards to the 'Cards' table, so the last card ID stored is 1.000.500. I want to

MySQL select statement returning results in circle mode

六月ゝ 毕业季﹏ 提交于 2020-05-16 10:55:12
问题 i am working with an app that via swipes you can see cards one after the other. Both left and right swipes are permitted. If the user swipes right he will see the next available card. If he swipes at the left he will see the previous card. The cards details are stored to a MySQL table 'Cards' and have a unique id let's say 'CardID' starting from number 1.000.000 and so on. Let's say that i currently have added 500 cards to the 'Cards' table, so the last card ID stored is 1.000.500. I want to

how to do a SELECT with a composite key?

◇◆丶佛笑我妖孽 提交于 2020-05-16 04:07:11
问题 I have a table with a composite key, and I want to do my SELECT query with that key, is there a way to put a name to the composite key or to do the query without having to add an AND let's say: SELECT * FROM MyTable WHERE PRIMARY KEY = 12345 being that primary key a composite key 回答1: No, there is no concept of SELECT * FROM MyTable WHERE PRIMARY KEY = 'PrimaryKeyName'. In other words, the predicate (WHERE clause) does not allow for this. You will need to list all columns that are contained

SQL join two tables with specific condition

て烟熏妆下的殇ゞ 提交于 2020-05-15 04:54:27
问题 Table A structure: Table B structure: Above are two tables, TableB.TableARelationID is a relationID which used to map table A. Desired output: The desired result would be taking TableA.RecordID and TableB.Text, but only of Type 2 in table B, i.e. ignore Type 1 Below is the SQL query which I used: SELECT tablea.recordid, tableb.text FROM tablea LEFT JOIN tableb ON tablea.relationid = tableb.tablearelationid WHERE type = 2 But the above query would output: i.e. RecordID 1 was missing, as the

SQL join two tables with specific condition

拟墨画扇 提交于 2020-05-15 04:53:44
问题 Table A structure: Table B structure: Above are two tables, TableB.TableARelationID is a relationID which used to map table A. Desired output: The desired result would be taking TableA.RecordID and TableB.Text, but only of Type 2 in table B, i.e. ignore Type 1 Below is the SQL query which I used: SELECT tablea.recordid, tableb.text FROM tablea LEFT JOIN tableb ON tablea.relationid = tableb.tablearelationid WHERE type = 2 But the above query would output: i.e. RecordID 1 was missing, as the

SELECT INTO with HSQLDB

偶尔善良 提交于 2020-05-13 05:04:17
问题 I am trying to create a new table from the result of a select. This works fine with SQL Server: SELECT * INTO newTable FROM (SELECT col1, col2, col3 FROM oldTable) x; Now, I want to achieve the exact same thing with HSQLDB (Version 2.2). I have tried several forms like SELECT * INTO newTable FROM (SELECT col1, col2, col3 FROM oldTable); SELECT INTO newTable FROM SELECT col1, col2, col3 FROM oldTable; CREATE TABLE newTable AS SELECT col1, col2, col3 FROM oldTable; All these variants result in

SELECT INTO with HSQLDB

让人想犯罪 __ 提交于 2020-05-13 05:01:09
问题 I am trying to create a new table from the result of a select. This works fine with SQL Server: SELECT * INTO newTable FROM (SELECT col1, col2, col3 FROM oldTable) x; Now, I want to achieve the exact same thing with HSQLDB (Version 2.2). I have tried several forms like SELECT * INTO newTable FROM (SELECT col1, col2, col3 FROM oldTable); SELECT INTO newTable FROM SELECT col1, col2, col3 FROM oldTable; CREATE TABLE newTable AS SELECT col1, col2, col3 FROM oldTable; All these variants result in

Setting the text of an <option> element using jQuery

梦想的初衷 提交于 2020-05-11 04:16:08
问题 Using jQuery what is the best way of editing option text for a given select value. I know the value of the option I want to edit. I thought it would be something like... $('#select').val().$('option').html('New Text'); But I am clearly missing something. 回答1: $('#select option[value="someValue"]').text("newText") could use .html instead of .text , if adding html content. 回答2: Something like this? $('#select').children('option').text('New Text'); Have a look at Selectors for more information

Setting the text of an <option> element using jQuery

邮差的信 提交于 2020-05-11 04:15:20
问题 Using jQuery what is the best way of editing option text for a given select value. I know the value of the option I want to edit. I thought it would be something like... $('#select').val().$('option').html('New Text'); But I am clearly missing something. 回答1: $('#select option[value="someValue"]').text("newText") could use .html instead of .text , if adding html content. 回答2: Something like this? $('#select').children('option').text('New Text'); Have a look at Selectors for more information