print sql code example

Example 1: Cast for print sql

declare @x INT = 1 

PRINT 'There are ' + CAST(@x AS VARCHAR) + ' alias combinations did not match a record'

Example 2: output data in sql

<?php
	/* Connect to your database */
	$con = mysqli_query("hostname", "username", "pwd", "database");
    /* Select Columns from table*/
    $sql = "SELECT * FROM `TABLE`";
    /* Query your SQL code to SQLDatabase */
    $result = mysqli_query($con, $sql);
    /* Find rows in table*/
    $check = mysqli_num_rows($result);
    if($check > 0){
    while($data= mysqli_fetch_assoc($result)){
    /* Print all of your data*/
    echo $data["ColName"];
    }
    }
?>

Example 3: sql query print strings and int

print 'There are ' + cast(@Number as varchar) + ' alias combinations did not match a record'

Tags:

Sql Example