Create a MySQL table named 'prime_test' that contains two columns. The first column is an integer named 'number' that is the primary key and cannot be NULL. The second column is a variable length string named 'is_prime' with a maximum length of 50. Write one or more insert statements that fills only the 'number' column of table 'prime_test' with the integers between 2 and 100. Write one or more update statements that sets the 'is_prime' column for each associated integer. For a prime, the column should read 'prime'. For non-primes, the column should read 'composite'. Write a final select statement to return only the 'number' column from 'prime_test' for records that are prime, ordered from largest to smallest.
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
I need SQL code for the following question :
Create a MySQL table named 'prime_test' that contains two columns. The first column is an integer named 'number' that is the primary key and cannot be NULL. The second column is a variable length string named 'is_prime' with a maximum length of 50.
Write one or more insert statements that fills only the 'number' column of table 'prime_test' with the integers between 2 and 100.
Write one or more update statements that sets the 'is_prime' column for each associated integer. For a prime, the column should read 'prime'. For non-primes, the column should read 'composite'.
Write a final select statement to return only the 'number' column from 'prime_test' for records that are prime, ordered from largest to smallest.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Its giving me an error in where statement saying isprime and !isprime doesn't exit
Thanks, It was really helpful, Is there way to interest the values using loop?