<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://bionmr.unl.edu/mediawiki/mediawiki/index.php?action=history&amp;feed=atom&amp;title=SQL_Examples</id>
	<title>SQL Examples - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://bionmr.unl.edu/mediawiki/mediawiki/index.php?action=history&amp;feed=atom&amp;title=SQL_Examples"/>
	<link rel="alternate" type="text/html" href="https://bionmr.unl.edu/mediawiki/mediawiki/index.php?title=SQL_Examples&amp;action=history"/>
	<updated>2026-05-26T06:35:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://bionmr.unl.edu/mediawiki/mediawiki/index.php?title=SQL_Examples&amp;diff=75&amp;oldid=prev</id>
		<title>Wiki Administrator: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://bionmr.unl.edu/mediawiki/mediawiki/index.php?title=SQL_Examples&amp;diff=75&amp;oldid=prev"/>
		<updated>2012-03-13T00:04:01Z</updated>

		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:04, 13 March 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Wiki Administrator</name></author>
	</entry>
	<entry>
		<id>https://bionmr.unl.edu/mediawiki/mediawiki/index.php?title=SQL_Examples&amp;diff=74&amp;oldid=prev</id>
		<title>MediaWiki default at 16:38, 14 March 2011</title>
		<link rel="alternate" type="text/html" href="https://bionmr.unl.edu/mediawiki/mediawiki/index.php?title=SQL_Examples&amp;diff=74&amp;oldid=prev"/>
		<updated>2011-03-14T16:38:58Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Below are some illustrative examples of [[:Wikipedia:SQL|SQL]] queries that may be run from the Bioscreen reports pages.&lt;br /&gt;
&lt;br /&gt;
==Basic SQL queries==&lt;br /&gt;
&lt;br /&gt;
===Query timestamps from a table===&lt;br /&gt;
&lt;br /&gt;
 ts &amp;#039;&amp;#039;&amp;#039;from&amp;#039;&amp;#039;&amp;#039; ligands&lt;br /&gt;
&lt;br /&gt;
This query will pull all timestamps (last-modified times) from the ligands table, and shows the basic &amp;#039;&amp;#039;entry1, entry2, ... from table1, table2 ...&amp;#039;&amp;#039; form of all SQL queries.&lt;br /&gt;
&lt;br /&gt;
===Query a limited amount of entries from a table===&lt;br /&gt;
&lt;br /&gt;
 name, uniprotID, annotation from proteins &amp;#039;&amp;#039;&amp;#039;limit 20&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This query highlights the use of the &amp;#039;&amp;#039;limit&amp;#039;&amp;#039; clause to limit the amount of results. This clause is most useful when paired with some &amp;#039;&amp;#039;order&amp;#039;&amp;#039; clause.&lt;br /&gt;
&lt;br /&gt;
===Query entries with specific values from a table===&lt;br /&gt;
&lt;br /&gt;
 molID, inchiKey, commonName from ligands &amp;#039;&amp;#039;&amp;#039;where nmrPlate = &amp;#039;1&amp;#039; and nmrWell like &amp;#039;a%&amp;#039;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This query shows the basic form of a query where only certain results are returned based on their field values. When an exact match is desired, an equals sign is required. Inexact matches require the use of &amp;#039;&amp;#039;like&amp;#039;&amp;#039;, and percent signs may be used as wildcards. It&amp;#039;s always best to use single-quotes around field values, even though they&amp;#039;re only required for strings.&lt;br /&gt;
&lt;br /&gt;
===Query a sorted list of entries from a table===&lt;br /&gt;
&lt;br /&gt;
 molID, inchiKey, commonName from ligands where nmrPlate=&amp;#039;1&amp;#039; and nmrWell like &amp;#039;a%&amp;#039; &amp;#039;&amp;#039;&amp;#039;order by estimatedPrice desc&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This query builds on the previous query by sorting the results according to price, in descending order (hence the &amp;#039;&amp;#039;desc&amp;#039;&amp;#039; qualifier). Simply omit the qualifier to sort in ascending order.&lt;br /&gt;
&lt;br /&gt;
===Query a numeric value from a table===&lt;br /&gt;
&lt;br /&gt;
 molID, mass from ligands where &amp;#039;&amp;#039;&amp;#039;mass &amp;lt; 100&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This query shows the numerical &amp;#039;&amp;#039;less-than&amp;#039;&amp;#039; operator being used in a query. Also worthy of note is the &amp;#039;&amp;#039;&amp;#039;&amp;lt;&amp;gt;&amp;#039;&amp;#039;&amp;#039; operator, which denotes inequality for numeric and non-numeric fields.&lt;br /&gt;
&lt;br /&gt;
===Query multiple values of a given field using subqueries===&lt;br /&gt;
&lt;br /&gt;
 molID, inchiKey, commonName, catalogNumber, mass from ligands where &amp;#039;&amp;#039;&amp;#039;nmrPlate in (1, 3, 5)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This query will return the relevant fields of all ligands table entries with nmrPlate values of 1, 3 &amp;#039;&amp;#039;or&amp;#039;&amp;#039; 5.&lt;br /&gt;
&lt;br /&gt;
==More advanced SQL queries==&lt;br /&gt;
&lt;br /&gt;
===Query using calculated fields===&lt;br /&gt;
&lt;br /&gt;
 molID, &amp;#039;&amp;#039;&amp;#039;concat(&amp;#039;P&amp;#039;, nmrPlate, nmrWell) as nmrPlateWell&amp;#039;&amp;#039;&amp;#039; from ligands where nmrPlateWell like &amp;#039;P2A%&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Multiple fields may be concatenated together and treated as one field in queries like so. In the above example, the &amp;#039;&amp;#039;nmrPlateWell&amp;#039;&amp;#039; field does not actually exist as a field in the ligands table, but is created on the fly using the values of other tables. the &amp;#039;&amp;#039;nmrActive&amp;#039;&amp;#039;, &amp;#039;&amp;#039;nmrMix&amp;#039;&amp;#039;, &amp;#039;&amp;#039;msActive&amp;#039;&amp;#039; and &amp;#039;&amp;#039;msMix&amp;#039;&amp;#039; ligands fields are more complex examples of this behavior.&lt;br /&gt;
&lt;br /&gt;
===Query fields involving multiple tables===&lt;br /&gt;
&lt;br /&gt;
 ligands.molID from &amp;#039;&amp;#039;&amp;#039;ligands, mixtures, mixture_ligands&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
   where mixtures.id = mixture_ligands.mixtureID&lt;br /&gt;
   and ligands.id = mixture_ligands.ligandID&lt;br /&gt;
   and mixtures.creator like &amp;#039;%brad%&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This query highlights the use of an implicit inner join (comma) to link two tables together. The above query links the &amp;#039;&amp;#039;ligands&amp;#039;&amp;#039; and &amp;#039;&amp;#039;mixtures&amp;#039;&amp;#039; tables together through the &amp;#039;&amp;#039;mixture_ligands&amp;#039;&amp;#039; table based on primary keys in the first two tables.&lt;br /&gt;
&lt;br /&gt;
[[Category:Bioscreen]]&lt;/div&gt;</summary>
		<author><name>MediaWiki default</name></author>
	</entry>
</feed>