Make proper sql