diff --git a/src/Carbunql/Fluent/SelectQuerySelectExtensions.cs b/src/Carbunql/Fluent/SelectQuerySelectExtensions.cs
index 04b50ed7..ca5c9410 100644
--- a/src/Carbunql/Fluent/SelectQuerySelectExtensions.cs
+++ b/src/Carbunql/Fluent/SelectQuerySelectExtensions.cs
@@ -47,9 +47,18 @@ public static SelectQuery SelectOnlyByNames(this SelectQuery query, IEnumerable<
return query;
}
+ ///
+ /// Adds a column selection to the query with an optional alias.
+ /// If the provided alias is null or empty, the column name will be used as the alias.
+ ///
+ /// The current SelectQuery object.
+ /// The alias of the table that contains the column.
+ /// The name of the column to select.
+ /// Optional alias for the column. If not provided or empty, the column name will be used.
+ /// The updated SelectQuery object.
public static SelectQuery Select(this SelectQuery query, string tableAlias, string column, string columnAlias = "")
{
- query.AddSelect($"{tableAlias}.{column}", columnAlias);
+ query.AddSelect($"{tableAlias}.{column}", string.IsNullOrEmpty(columnAlias) ? column : columnAlias);
return query;
}
diff --git a/src/Carbunql/IQuerySource.cs b/src/Carbunql/IQuerySource.cs
index c2d0d71b..26f937ad 100644
--- a/src/Carbunql/IQuerySource.cs
+++ b/src/Carbunql/IQuerySource.cs
@@ -1,5 +1,6 @@
using Carbunql.Building;
using Carbunql.Clauses;
+using Carbunql.Extensions;
using Carbunql.Tables;
namespace Carbunql;