How the sql query to sort the records by variable
Feel like using PHP to know how to write the query SQL ORDER BYvalue time from list/menu form field ("sort_menu") and the values in the list are the columns of the database
SELECT *.
OF rentals_info
WHERE rentals_info.active = 'yes '.
Thanks for your help,
Jim balthrop
JBWebWorks wrote:
> Using fault PHP to know how to write the query to sql ORDER BY
> run time value from list/menu form field ("sort_menu") and the list
> values of the database columns
Unfortunately, you can not use the Dreamweaver Recordset dialog box to set
a column of the table as a variable. You need to adapt the code by hand, and
Once you do, the recordset can be is no longer recognized by
Dreamweaver. Thus, you must have first page in case the
Bindings panel shows more the fields in your recordset.
Begin by creating the Recordset without the ORDER BY clause and have
your page as you want it. When everything is done, add the following
code at the top of the page:
<>
create a table of column names that can be used for sorting
$permitted = array ("price", "space");
checks if the sort_menu variable contains a valid column name
If (isset($_GET['sort_menu']) & in_array ($_GET ['sort_menu'], $permitted)) {}
$sort = $_GET ['sort_menu'];
} else {}
the value of a default column for sorting
$sort = "price".
}
?>
This assumes that the sort columns are called price and region.
Change these values according to your configuration.
You can now add ORDER BY $sort to the SQL of the Recordset.
--
David powers
Adobe, Dreamweaver community expert
http://foundationphp.com
Tags: Dreamweaver
Similar Questions
-
How the records are selected in the database
Hello
How the records are selected in the database
Thank you.
Read articles on JDBC, here is what I understand...
If I set LignesMax = 1 (in out select adapter DB) and I have 30 record in the table that satisfy the select query then what line is picked up? the first in the table or randomly any folder?
The query returns the first line of the result set. Not just a random line. However, to get the rows to return in the result set in a specific order, you must include an order by clause, or the query will return rows in random order.
And if I set LignesMax = 0 (unbounded, means any number registration) in this case if my select query satisfy 100 million documents so all million records will be picked up once, in one cycle?
The answer to this depends on the size of the extraction of the query. If the size of the extraction is > = 100 million, everything goes back in a single cycle of the DB. If< 100="" million,="" then="" it="" will="" be="" divided="" into="" multiple="" trips="" to="" the="">
-
An associative array, how the records using the loop counter?
In the associative array, how the records using the loop counter? for example
declare type population is table of number index by varchar2(64); city_population population; begin city_population('Samillve') := 200; city_population('Lindenhurst') := 300; for i in 1 .. city_population.count loop dbms_output.put_line(city_population(i)); -- compiler error end loop; end; /
That would look like
SQL> ed Wrote file afiedt.buf 1 declare 2 type population is table of number index by varchar2(64); 3 city_population population; 4 l_index varchar2(64); 5 begin 6 city_population('Samillve') := 200; 7 city_population('Lindenhurst') := 300; 8 l_index := city_population.first; 9 while( l_index IS NOT NULL ) 10 loop 11 dbms_output.put_line(city_population(l_index )); 12 l_index := city_population.next(l_index); 13 end loop; 14* end; SQL> / 300 200 PL/SQL procedure successfully completed.
Justin
-
How the names of variables and units used in the binary output file
My colleague will give me LabView generated from the binary files (*.dat). There are more than 60 variables (columns) in the binary output file. I need to know the names of variables and units, which I think he has already configured in LabView. Is there a way for him to produce a file that contains the name of the variable and unity, so that I'll know what contains the binary file? It can create an equivalent ASCII file with a header indicating the name of the variable, but it does not list the units of each variable.
As you can tell I'm not a user of LabView, so I apologize if this question makes no sense.
Hi KE,.
an ASCII (probably the csv format) file is just text - and contains all data (intentially) written to. There is no special function to include units or whatever!
Your colleague must save the information it records the names and values in the same way...
(When writing to text files, it could use WriteTextFile, FormatIntoFile, WriteToSpreadsheetFile, WriteBinaryFile even could serve...)
-
How the PATH environment variable longer?
Hello
I use Windows Vista Business. Lately, I just installed the beta of Intel Parallel Studio and found that my path variable ran out of space. Internet research concluded that there cannot be more than 1024?It is too little for me to welcome all directories program that I installed, and thus some programs no longer work correctly.I wonder if there-(a) is a way I can expand the size of the Path system variable?(b) add another variable which can take some Path variable values so that I do not violate the limitation of 1024.Thanks in advance!AHello, Gutsingh
The PATH environment variable has a fixed limit of 1023 characters can be used. It doesn't seem to be a way to extend this. Other environment variables have a higher limit, which can be useful.
Let us know if that helps.
David
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think. -
Stuck on a sql query to search for records that have the same parent child records
Oracle 10 g 2 Enterprise Edition.
Hello
I'm writing a logic to find records in a parent table, who have the same values in a child table.
This is part of a larger application, but I am stuck on that part for now, so I have mocked some of the below simplified tables to capture the heart of the
the problem is that I'm stuck.
Let's say I have a responsible parent, child employee table table and there are a number of many relationships between them.
The aptly named Join_Table manages the relationship between them. If a manager can manage several employees, an employee can be managed by
many managers.
I have a feeling it's stupidly easy, but it seems to me having a bad episode of brain freeze today!
If I ask for Manager John, so I want to find other managers who manage the exact list and even employees.-- parent table CREATE TABLE manager ( id number primary key, name varchar2(100)); -- child table CREATE TABLE employee ( id number primary key, name varchar2(100)); -- link table CREATE TABLE join_table ( manager_id NUMBER, employee_id NUMBER, CONSTRAINT join_table_pk PRIMARY KEY (manager_id, employee_id), CONSTRAINT manager_fk FOREIGN KEY (manager_id) REFERENCES manager(id), CONSTRAINT employee_fk FOREIGN KEY (employee_id) REFERENCES employee(id) ); -- Insert some managers INSERT INTO manager (id, name) VALUES (1, 'John'); INSERT INTO manager (id, name) VALUES (2, 'Bob'); INSERT INTO manager (id, name) VALUES (3, 'Mary'); INSERT INTO manager (id, name) VALUES (4, 'Sue'); INSERT INTO manager (id, name) VALUES (5, 'Alan'); INSERT INTO manager (id, name) VALUES (6, 'Mike'); -- Insert some employees INSERT INTO employee (id, name) VALUES (101, 'Paul'); INSERT INTO employee (id, name) VALUES (102, 'Simon'); INSERT INTO employee (id, name) VALUES (103, 'Ken'); INSERT INTO employee (id, name) VALUES (104, 'Kevin'); INSERT INTO employee (id, name) VALUES (105, 'Jack'); INSERT INTO employee (id, name) VALUES (106, 'Jennifer'); INSERT INTO employee (id, name) VALUES (107, 'Tim'); -- Insert the links -- John manages Paul, Simon, Ken INSERT INTO join_table (manager_id, employee_id) VALUES (1, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (1, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (1, 103); -- Bob manages Paul, Simon, Kevin, Jack INSERT INTO join_table (manager_id, employee_id) VALUES (2, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 104); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 105); -- Mary manages Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (3, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (3, 107); -- Sue manages Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (4, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (4, 107); -- Alan manages Paul, Simon, Ken, Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (5, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 103); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 107); -- Mike manages Paul, Simon, Ken INSERT INTO join_table (manager_id, employee_id) VALUES (6, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (6, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (6, 103); -- For sanity CREATE UNIQUE INDEX employee_name_uidx ON employee(name);
Answer should be Mike.
If I ask for Manager of Mary, the answer should be Sue.
This query will give me the list of managers who manage some of the same employees as John, but not the same employees accurate...
I thought about using set operations to find managers with a list of employees less than my employees is null and where my employees under their list of employees is null. But there must be an easier way more elegant.SELECT DISTINCT m.name AS manager FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND e.id IN ( SELECT e.id FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND m.name = 'John') ORDER BY 1;
Any ideas?
BTW, I need to run as a batch on tables with > 20 million rows so the efficiency of queries is key.What about...
WITH manager_list AS ( SELECT name, LTRIM(MAX(SYS_CONNECT_BY_PATH(id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees FROM (SELECT m.name, e.id, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND m.name = :P_MANAGER) GROUP BY name CONNECT BY prev = PRIOR curr AND name = PRIOR name START WITH curr = 1 ), all_list AS ( SELECT name, LTRIM(MAX(SYS_CONNECT_BY_PATH(id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees FROM (SELECT m.name, e.id, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id) GROUP BY name CONNECT BY prev = PRIOR curr AND name = PRIOR name START WITH curr = 1 ) SELECT a.* FROM manager_list m, all_list a WHERE m.employees = a.employees
Would be easier in 11g, but I do not have a facility here so this is based on 10g.
See you soon
Ben
-
How the value of variable Page of Backing Bean
Hi all
New on ADF trying to access page variable value to a BackingBean (scope wonders).
I tried this approach but does not work, I do not know how to solve.
My ADF page is filled by a VO.
It is the ADF page code:
< af:panelLabelAndMessage label = "Name" id = "plam8" >
< af:outputText value = "#{bindings." Name.inputValue}"id ="ot7">
< / af:outputText >
< / af:panelLabelAndMessage >
< af:panelLabelAndMessage label = 'Start Date' id = 'plam8' >
< af:outputText value = "#{detailBean.startDate.inputValue}" id = "ot8" / > "
< / af:panelLabelAndMessage >
This is the piece of my BackingBean where I need to read my element value and the format in right way and then push it down on the page of the ADF:
private String startDate;
public String getStartDate() {}
StartDateXD = (Date) resolveExpression("#{pageFlowScope.startDate}");
If (startDateXD ! = null) {}
In the date format = new Date (startDateXD. getTime());
SimpleDateFormat newFormat = new SimpleDateFormat("dd/MM/yyyy");
startDate = newFormat.format (formatted);
}
Return dataSds;
}
Is someone coulfd help me?
Thanks for your help.
Fairlie
Yes, you can use af:convertNumber to convert currency. Check Ashish Awasthi (Jdev/ADF) Blog: change of af: convertNumber Format according to the regional settings - Oracle ADF for a sample.
Timo
-
Hallo!
I tried to use the recorder with variable units. It does not it? Can I change the units of the recorder of the version of the runtime somehow?
Thanks for your advice.
Hilby
Hello again!
I found the solution:
Even when it is not possible to use a variable in the context menu, it is possible to put a global string in the recorder manually. I put "${Unit_Ch1}" on the ground for the unit, and it worked.
Have a good day everyone.
-
I have a lot of issues of brand book with websites contained in each folder. I'm able to sort sites within each folder alphabetically by name, but I can't find a way to sort the records themselves in alphabetical order by name. I speak not in a display mode, but in how they appear when I click on the tab my favorites. Can someone explain to me how to do other than manually by dragging because it is extremely difficult for me, due to the fact that I am with limited movement tetraplegic hand dexterity
Folders of bookmarks you created are in the folder Menu bookmarks. "Sort" this folder.
-
How to get the value of a column in sql query?
Hi, anyone knows how to get the value of a column in sql query?
Here is my code, the value must be 1350079224397 in my PB, but I get 0
QString query ("SELECT version FROM db_version");
QVariant result = sda.execute (query);
QVariantMap versionMap = result.toList () such () .toMap ();
If (! versionMap.IsEmpty ())
{
qDebug()<"Version: "="">"Version:><>
}OK, I have the solution
QString query ("SELECT version as version FROM db_version");
-
How to do a validation based on the SQL query?
Hello
I have a requirement to perform a validation on a field (messageTextinput) in my page OAF.
When I click the button apply, the value in this field is validated based on a SQL query (for example, the value in the field NOT IN (value1 select from table1).)
Help, please.
Best regards
Joe
1. create a SQL query based VO, XXVO. For example:-SQL query is select xx_table;
2. Enter the "Apply" button click event in the controller and run the AM method passing the value entered by the user in the given field, for example:-value is VAL1
3. in the method of the AM, get a handle of the VO, the whereClause and run.
OAViewObjectImpl vo = findViewObject ("XXVO1"); XXVO1 is the name of the instance of the VO above, XXVO
vo.executeEmptyRowSet ();
vo.setWhereClause (null);
vo.setWhereClause ("value =" + VAL1 + "'");
vo.executeQuery ();
If (VO. GetRowCount() > 0)
A record is with the value of VAL1. Perform the required action
I hope this helps.
-
How do I get the data of "Regulatory BOM" Formulation with SQL query output
Hello
We would like to implement a State of BiPublisher that displays "Regulation BOM" (wording-> click on TAB Formulation on exit Popup-> TAB Composition) information table.
How could get us this information with an SQL query?
Thank you
Annarosa
Hi, given 'Regulatory BOM' output of the Formulation are more complicated than expected. Attached is an example. You can test and make the appropriate changes to your report.
-
How to display time in 010403 format if the entry is transmitted as ' 1 hour, 4 minutes, 3 seconds"sql query @.
Hello
You can try:
Select lpad (regexp_substr ('1 hour, 4 minutes, 3 seconds ',' [[: digit:]] + ""), 2, '0')
|| LPAD (regexp_substr ('1 hour, 4 minutes, 3 seconds ',' [[: digit:]] +', 1, 2), 2, '0')
|| LPAD (regexp_substr ('1 hour, 4 minutes, 3 seconds ',' [[: digit:]] +' 1, 3), 2, '0')
Double;
but this requires maximum 99 hours/minutes/seconds ago in your entry.
-
SQL query to retrieve a single record for each employee of the following table?
Hi all
Help me on the writing of SQL query to retrieve a single record for each employee of the following table? preferably a standard SQL.
CREATE TABLE xxc_contact)
empnum NUMBER,
alternatecontact VARCHAR2 (100),
relationship VARCHAR2 (10),
phtype VARCHAR2 (10),
Phone NUMBER
);
insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Cell', 9999999999)
insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Work', 8888888888)
insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Work', 7777777777)
insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Home', 3333333333)
insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Cell', 9999999999)
insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Home', 9999999999)
expected result:
EmpNum AlternateContact Relationship PhType Phone
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
Thanks in advance.
994122 wrote:
Thank you all, that I got a result
http://www.orafaq.com/Forum/m/620305/#msg_620305
By Lalit Kumar B...
Specifically, the two simple solutions provided were:
1 using the row_number, entitled Oracle ranking based on descending order of the inside telephone each empnum group. And finally selects the lines which has least rank (of least since that order is descending for phone).
SQL > column alternatecontact format A20;
SQL >
SQL > SELECT empnum, alternatecontact, relationship, phtype, phone
2 from (SELECT a.*, row_number() over r (PARTITION BY empnum ORDER BY phone / / DESC))
3 FROM xxc_contact one)
4. WHEN r = 1
/
EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE
---------- -------------------- ---------- ---------- ----------
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
2. with the help of MAX, Oracle automatically assigns the maximum phone for all the rows in each group of empnum. And finally selects the rows with the maximum phone. Order by clause is omitted here intentionally. You can find out why.
SQL > SELECT empnum, alternatecontact, relationship, phtype, phone
2 (SELECT a.*, MAX (phone) over (PARTITION BY empnum) rn FROM xxc_contact one)
3 WHERE phone = rn
4.
EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE
---------- -------------------- ---------- ---------- ----------
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
Kind regards
Lalit
-
How to select only the part by using the sql query
Hello
I have the task to retrieve only the integral of the input text by using the sql query.
The entry is as follows
Entry for the price setting
$12.5 (FYI without space)
$ 12.5 (FYI single space)
$ 12.5 (double space FYI)
$12.5 (FYI multiple space)
$12.5 (FYI multiple space)
Output expected of 12.5
The price is the type varchar2 column in the store_price table.
Please let me know how to achieve this.
Thanks in advance.
If this is always the case that you get a $ followed by a number of places, you can use something like:
Select to_number (ltrim ('$ 12.5',' $')) DOUBLE
or
SELECT ltrim ('$ 12.5',' $') OF double
but take care of your nls_numeric_character settings if they are defined so that, for example, a comma is the decimal separator, you will have a problem.
HTH
Maybe you are looking for
-
Can my photo stream - I import but not export the photos?
I want to import photos from my Macbook to my Mac desktop, but I don't want every photo that I load on my Office Mac sent to my Macbook. If I turn my photo stream at the same time a copy of each photo on both devices. I just want to really use the
-
Apple's music will not change the song on shuffle mode
My iphone6 will not change the songs Apple music in shuffle mode. Once selected the song again and again.
-
I need BIOS F.1C SP66846 for HP 14-b046tu
I need BIOS F.1C SP66846 for HP 14-b046tu The BIOS: F.1C SP66846SP66846.exe When I tried, it has not 2 times on "HP Support Assistant" and there it no file named "SP66846.exe" in the web page. FTP://ftp.HP.com/pub/SoftPaq/sp66501-67000/SP66846.exe 55
-
Use of Variables shared with RT-project / home-VI
Hi all I have a small question which is certainly easy to answer for those who have already worked with a RT - VI containing two periods loops and a user interface that is deployed on a host PC. Q: is there an advantage to the data acquisition in the
-
MP3 files have changed. IDX on external hard drive and can not open
Original title:. IDX FILES My HD has all my music files. Somehow, the files have changed MP3 for. IDX I can't open an any of them. Microsoft does not support. I want back my music files. How can I do this? Help please! I am computer illiterate.