[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/mkitzan/constexpr-sql/master/example.cpp [Back]  [Original]

#include 
#include 

#include "sql.hpp"

using books =
	sql::schema<
		"books", sql::index,
		sql::column,
		sql::column,
		sql::column,
		sql::column
	>;

using authored =
	sql::schema<
		"authored", sql::index,
		sql::column,
		sql::column
	>;

using query =
	sql::query<
		"SELECT title AS book, name AS author, year, pages "
		"FROM books NATURAL JOIN (SELECT * FROM authored WHERE name = \"Harlan Ellison\") "
		"WHERE year = 1967 OR year >= 1972 AND genre = \"science fiction\"",
		books, authored
	>;

int main()
{
	authored a{ sql::load("tests/data/authored.tsv", '\t') };
	books b{ sql::load("tests/data/books.tsv", '\t') };

	for (query q{ b, a }; auto const& [book, author, year, pages] : q)
	{
		std::cout 

Web Proxy Viewer  |  New URL  |  Original Page